Reply
301 redirect code on windows servers?
Old 02-07-2008, 11:25 AM 301 redirect code on windows servers?
adp
Novice Talker

Posts: 10
Name: joe
we launched a new site and I want to properly redirect the pages on the old version of the site which are indexed in the SE's over to the cooresponding pages on the new site. most of these pages are .htm pages (some are .asp). Here is what I was doing:

I would simply delete the info on the page and replace it with this code:

<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "http://www.adproductsco.com/productc...idCategory=530"
%>

and then upload the page to the server. When I visited the old page I expected it to re-direct over to the new site but it just comes up blank. I feel like this should be a simple task but it is proving to be more frustrating than anything.

I would appreciate any advise!
adp is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 02-07-2008, 11:31 AM Re: 301 redirect code on windows servers?
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Good question, dude.

1) Add Response.End under the Response.AddHeader line. If you don't, Googlebot will throw an error.

2) ASP code won't work on HTML pages no matter what you do. You not only have to delete the info, you'll have to delete the page as well and use a custom 404 to perform your redirects. Make sure you use the 301 code that you've got though (plus the Response.End line) and not the Response.Redirect (as Response.Redirect will generate a 302 status code).

To simplify this a bit:

Delete all HTML pages.
Install custom 404 on your site. Note: you will need either access to your server or a host that will set up custom 404 pages for you. You can't just upload them and expect them to work. They don't. (I've made that mistake before, 8 years ago.)
Have custom 404 examine old URL (http://www.your-domain.com/your-old-url.html) and have it go to new URL (http://www.your-domain.com/new-produ...oductID=123456).

That's about the simplest I can make this for you. Good luck!
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 02-07-2008, 11:37 AM Re: 301 redirect code on windows servers?
adp
Novice Talker

Posts: 10
Name: joe
thanks for the info... can you give me some ideas on how to:

Have custom 404 examine old URL (http://www.your-domain.com/your-old-url.html) and have it go to new URL (http://www.your-domain.com/new-produ...oductID=123456).
adp is offline
Reply With Quote
View Public Profile
 
Old 02-07-2008, 12:19 PM Re: 301 redirect code on windows servers?
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
The code is more or less on the custom 404 page I linked to. All you have to do is apply it to your specific situation and adjust the Response.Redirect lines to reflect the 301 code you have above.

How you do that...well...there are about a million different ways, and it really depends on what you're ultimately trying to accomplish in detail. That's not really something I can answer.
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Reply     « Reply to 301 redirect code on windows servers?
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13853 seconds with 13 queries