Welcome to WebmasterWorld Guest from 54.160.131.144

Forum Moderators: ocean10000

Message Too Old, No Replies

How to set up a 301 redirect

Easy instructions please

     

super_seo

10:08 am on May 14, 2004 (gmt 0)

10+ Year Member



Iím trying to create a 301 redirect from [mysite.com...] to [mysite.com...]
How do I do this?

IES spy sayís Iíve got to change the IP address of mysite.com and then use code to redirect to www.mysite.com. Is this the only way yo do it in IIS5? That sounds a bit scary, changing the I.P address..

Can I do this DNS, i have full access to my DNS?

I really need a straight easy to follow explanation on this.
Anyone help please?

raptorix

12:32 pm on May 14, 2004 (gmt 0)

10+ Year Member



Just create a website with a default.asp file with script:

response.redirect("http://www.domain.com/")

Don't think it matters where the site is hosted.

mattglet

2:12 pm on May 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Response.Redirect() is actually a 302 (Temporary Move).

You need to do this for a 301:

<%
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://www.example.com/yourpage.asp"
%>

-Matt

super_seo

4:52 am on May 15, 2004 (gmt 0)

10+ Year Member



Not sure if I'm understanding this correctly.

---

Just create a website with a default.asp file with script:

So i have to change the IP address? Not really viable as the site is in all search engines, a new IP will course alsorts of problems with them?
This is the first time i've had to set this up and if the clients website has to start a fresh in the search engines i'm hung, drawn and diced into tiny pieces.
Is there no other way i can create this?

mattglet

4:21 pm on May 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, you don't have to change the IP address. On any page that you want to redirect, put the code I posted above at the very top of the page. replace "example.com/yourpage.asp" with your site/page you want to redirect to.

-Matt

super_seo

4:10 am on May 16, 2004 (gmt 0)

10+ Year Member



I think we've lost focus of the original question, or i'm being very stupid. Sorry i am a beginner.

I know how to do a redirect in code, i am asking to do a redirect from example.com to www.example.com, at any stage

The DNS points both example.com and www.example.com to the same I.P address in IIS. To use this code, as your correctly mention above, i would need to set up a new 'dummy' website in IIS with a new I.P address, so when someone omits the www it will go to this new site and then use the code mentioned to redirect to the correct www site. This as i see it, needs a new I.P address for a 'dummy' website, which i desperatly want to avoid. So can this be done without a 'dummy' website?

chrisgarrett

4:51 pm on May 16, 2004 (gmt 0)

10+ Year Member



Are you wanting to do a redirect if the user or bot goes to whatever.com rather than www.whatever.com? All you need to do is provide an include in every page that checks SERVER_NAME server variable and if it finds no 'www.' does the 301 with the headers mentioned above.

Have I understood the problem correctly?

Chris

super_seo

5:08 am on May 17, 2004 (gmt 0)

10+ Year Member



Yes thatís what I want to do but unfortunately Iíve got 20,000+ pages on the site.
Placing the code on every page isn't really an option. I need universal way of making this happen.

chrisgarrett

6:45 am on May 17, 2004 (gmt 0)

10+ Year Member



If it is a dedicated/co-lo server you can add a new site to IIS and set the host header URL in the settings. Set that site to have a permanent redirect to the www. version. You do not need a new IP for that, they determine which is which via the url the user uses (its a http 1.1 thing).

Chris

 

Featured Threads

Hot Threads This Week

Hot Threads This Month