•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 361,943 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,617 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 837 | Replies: 6 | Solved
![]() |
hello, I'm in the process of upgrading a site's pages from htm static content to a dynamix aspx page. the problem is that I want to redirect users visiting the old pages to the new pages and I want to use the proper 301 "moved permanently" redirect to be search engine-friendly. Unfortunately I can't figure out any way to do this! the extension is htm, so I can't embed any server-side scripting to redirect the user and change the response code...
I know I can do a meta or javascript refresh but that's not the proper way to do it. I tried doing a redirect in IIS but I could only redirect a folder, not an individual file (this is IIS 7 by the way).
I thought maybe I could force asp.net to handle the htm extension and inject the redirect code that way but I couldn't figure out how to do it properly. Is there any other way to do a 301 redirect without using server side scripting or htaccess? I seem to be stuck and will probably just have to do the meta refresh
any help is appreciated, thank you!
I know I can do a meta or javascript refresh but that's not the proper way to do it. I tried doing a redirect in IIS but I could only redirect a folder, not an individual file (this is IIS 7 by the way).
I thought maybe I could force asp.net to handle the htm extension and inject the redirect code that way but I couldn't figure out how to do it properly. Is there any other way to do a 301 redirect without using server side scripting or htaccess? I seem to be stuck and will probably just have to do the meta refresh
any help is appreciated, thank you!
You are somebody, just as I am somebody... but in the end, when you REALLY think about it, we are all nobody...
•
•
Join Date: Apr 2008
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 1
By using 301 redirects your site won't be search engine friendly. 301s will help you transfer pagerank from existing pages to new ones. But if the new URLs are in the form of index.asp?a=this&b=that&z=blah, then google won't be that happy.
So if you currently have structured URLs you better keep your existing urls by doing internal URL rewriting such as
/this/that/blah.htm to /index.asp?a=this&b=that&z=blah
or if no strucured URLs exist, create a new structured URL schema, redirect old urls to new structured ones, and rewrite the structured ones to the real .asp url. For example:
Redirect /goofy.htm to /this/that/blah.htm
and
Rewrite /this/that/blah.htm to /index.asp?a=this&b=that&z=blah
This way both your visitors and google will be happy. The most effective way to do such rewriting/redirection stuff is using a tool like Apache mod_rewrite and .htaccess. The best tool I know for IIS is IIS Mod-Rewrite Pro, but you can also find more tools at this wikipedia entry. All you need is a script like this:
RewriteEngine On
RewriteRule ^goofy.htm$ /this/that/blah.htm [R=301,L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)\.htm$ /index.asp?a=$1&b=$2&z=$3 [L]
But for god's sake don't use meta refresh tags or client side scripts if you want to save your precious existing pagerank.
So if you currently have structured URLs you better keep your existing urls by doing internal URL rewriting such as
/this/that/blah.htm to /index.asp?a=this&b=that&z=blah
or if no strucured URLs exist, create a new structured URL schema, redirect old urls to new structured ones, and rewrite the structured ones to the real .asp url. For example:
Redirect /goofy.htm to /this/that/blah.htm
and
Rewrite /this/that/blah.htm to /index.asp?a=this&b=that&z=blah
This way both your visitors and google will be happy. The most effective way to do such rewriting/redirection stuff is using a tool like Apache mod_rewrite and .htaccess. The best tool I know for IIS is IIS Mod-Rewrite Pro, but you can also find more tools at this wikipedia entry. All you need is a script like this:
RewriteEngine On
RewriteRule ^goofy.htm$ /this/that/blah.htm [R=301,L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)\.htm$ /index.asp?a=$1&b=$2&z=$3 [L]
But for god's sake don't use meta refresh tags or client side scripts if you want to save your precious existing pagerank.
You should set this up in IIS using an http redirect.
You just need to have the file highlighted then in features view select http redirect then specify the new address in the box and check the two options for exact location and not the subdir and select the return code. and that should work
edit:
this is what it creates in your web.config
You just need to have the file highlighted then in features view select http redirect then specify the new address in the box and check the two options for exact location and not the subdir and select the return code. and that should work
edit:
this is what it creates in your web.config
<location path="test.htm">
<system.webServer>
<httpRedirect enabled="true" destination="http://test.com/test.aspx" exactDestination="true" childOnly="true" httpResponseStatus="Permanent" />
</system.webServer>
</location> Last edited by peter_budo : Apr 4th, 2008 at 4:47 am. Reason: Keep It Organized - please use [code] tags
•
•
•
•
You should set this up in IIS using an http redirect.
You just need to have the file highlighted then in features view select http redirect then specify the new address in the box and check the two options for exact location and not the subdir and select the return code. and that should work
edit:
this is what it creates in your web.config
<location path="test.htm">
<system.webServer>
<httpRedirect enabled="true" destination="http://test.com/test.aspx" exactDestination="true" childOnly="true" httpResponseStatus="Permanent" />
</system.webServer>
</location>
thank you for your reply! would it be possible just to put this in the web.config file for each page and be done with it? or do I have to do something in IIS to make it work?
EDIT: okay I tried it in the web.config and it didn't work. I tried to follow your IIS instructions, but after highlighting the file and switching to Features View, there is no entry for httpredirect. is there something else I need to enable? thanks!
Last edited by SelArom : Apr 3rd, 2008 at 12:08 pm.
You are somebody, just as I am somebody... but in the end, when you REALLY think about it, we are all nobody...
•
•
•
•
thank you for your reply! would it be possible just to put this in the web.config file for each page and be done with it? or do I have to do something in IIS to make it work?
EDIT: okay I tried it in the web.config and it didn't work. I tried to follow your IIS instructions, but after highlighting the file and switching to Features View, there is no entry for httpredirect. is there something else I need to enable? thanks!
the web.config needs to be at the root of your old site.
looks like this fully written out.
This can be entered as many times as you need, im not sure if there is an easier way to write it though.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<--...other configs...-->
</system.web>
<location path="test.htm">
<system.webServer>
<httpRedirect enabled="true" destination="http://mini-server.dyndns.ws/" exactDestination="true" childOnly="true" httpResponseStatus="Permanent" />
</system.webServer>
</location>
</configuration>im not sure why your not seeing http redirect.
try going to content view then right clicking on the file and select feature view.
it will say: filename.htm Home instead of WebsiteName Home at the top of the feature view.
the option is under the IIS group in the features view.
Last edited by plazmo : Apr 3rd, 2008 at 2:28 pm.
thanks again for the reply, I tried as you suggested, right-clicking and selecting features view, it does work as you described, showing the file instead of the website, but there is still no option to add a redirect. I would imagine that this is the reason it isn't working even when I add the code manually to web.config. Is there an option I need to be checking that enables redirects site-wide?
many thanks
many thanks
aHA!! stumbled on this entry: http://blog.torresdal.net/2006/12/27...ectOnIIS7.aspx
turns out the damn thing wasn't installed! enabled it and it works like a charm!!
thanks for your help!
turns out the damn thing wasn't installed! enabled it and it works like a charm!!
thanks for your help!
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
Similar Threads
- Higher search engine rank? (Search Engine Optimization)
- Where do i start? (Search Engine Optimization)
- <h1><h2> and <b> tags (Search Engine Optimization)
- trying to improve my site (Search Engine Optimization)
Other Threads in the ASP.NET Forum
- Previous Thread: Populating a dropdown with data from an SqlServer stored procedure
- Next Thread: analys the programm and reply


Linear Mode