Forum Moderators: open

Message Too Old, No Replies

301 in IIS - help understanding

redirect with 301 command in 404?

         

lfhill

6:55 pm on Mar 25, 2004 (gmt 0)

10+ Year Member



I am trying to understand the 301 redirect page better. Please let me know if I understand this correctly. If I were moving a website from 1 ip to another, I would first create a 404 error handling page. Next, on that 404 page, I would add an asp script:

<%
Response.Status = "301 Moved Permanently"
Response.addheader "Location", "http://www.newdomain.com/newurl/"
Response.End
%>

Thus creating my 301 redirect page and communicating to the Search Engines that the site has moved.

I don't understand where else I could put a 301 command on a Microsoft IIS server.

Xoc

8:19 pm on Mar 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is also a place in the IIS manager that you can tell it to redirect a request for a resource to another location.

TheNige

10:16 pm on Mar 31, 2004 (gmt 0)

10+ Year Member



It only works in IIS if that file still exists. You can go into the IIS manager and set it to redirect to where you want to. But, if you want to catch access to a file that no longer exists, or was re-named then I believe that you need to use the 404 page that you have described above.

zgb999

9:13 am on Apr 1, 2004 (gmt 0)

10+ Year Member



Is it possible to have a 301 redirect from [domain.com...] to [domain.com...] by using a 404 page on IIS?

Or what options do I have for such a redirect if I cannot get a host to change the server settings?

martyt

3:09 pm on Apr 1, 2004 (gmt 0)

10+ Year Member



lfhill

That's pretty much how I do it, except slightly more advanced. I've got a text file on the site that lists *all* the "oudated" pages and the appropriate redirect, and the custom 404 page figures out where to redirect based on that file. The 404 page also handles real errors more gracefully.

If you have a lot of old pages in the search engines, you'll want to make sure you have an appropriate redirect for each one of them - both so the spiders will eventually pick up the new page and so your visitors will land in the right place. Hard-coding every one of those redirects in the script seems like a lot of work; adding one to a simple text file is a lot easier.

My site is in ASP.NET but I think the code I used to do my custom 404 page was in straight ASP before I converted it, and I *think* I found it in a search of this forum. If you haven't already, spend a few minutes searching here and see what you come up with.

[edit]
So I did the searching for you... ;-)

Try these links:

[webmasterworld.com ]
[evolvedcode.net ]