PDA

View Full Version : 301 permanent redirect on IIS: how to do it?



Emark2009
04-25-2006, 11:25 AM
hi,
i asked my hosting-provider to make a 301 permanent redirect from visitnatalbrazil.com to www.visitnatalbrazil.com and this for SEO-purpose.

My hosting-provider says i'm the first one who ask him this..

What is the best way to do this and can he charge me an extra cost for this?

ADAM Web Design
04-25-2006, 11:31 AM
It's really quite simple.

Your host would merely have to set up visitnatalbrazil.com as a new site and initially point it to the same folder as www.visitnatalbrazil.com .

When they've done that, they need to visit the Properties of the visitnatalbrazil.com site, and click the Home Directory tab. There's an option there to redirect to a URL, which they would pick and type in http://www.visitnatalbrazil.com and check the "A permanent redirection for this resource" box.

That's it.

They can charge you for anything they want, and since this is non-standard they might. I can't say for sure, although it's about a two-minute job in IIS.

Easywebdev
04-25-2006, 12:27 PM
You should never need to redirect domain.com to www.domain.com.

If domain.com is not appearing and www.domain.com is then your host has misconfigured your dns settings. Your dns settings should have an A record for both domain.com and www.domain.com

Doing a dnsreport on your site throws up a lot more problems than a missing A record, you need to get your host to sort out their server, nameservers and dns, it is an absolute mess.

http://www.dnsreport.com/tools/dnsreport.ch?domain=visitnatalbrazil.com

ADAM Web Design
04-25-2006, 07:31 PM
He might for SSL reasons.

Easywebdev
04-25-2006, 08:15 PM
He might for SSL reasons.

Only in the above misconfigured dns scenario.

A properly configured domain will have A records for both the domain.com and the www.domain.com so even when using a secure cert https://domain.com and https://www.domain.com are exactly the same site and will serve the same security certificate.

Emark2009
04-26-2006, 12:10 PM
is there a way to solve this with scripting? that way i don't need my host..

i use ASP.

ADAM Web Design
04-26-2006, 01:45 PM
Dim Domain, URL
Domain = Request.ServerVariables ("HTTP_HOST") ' Gets the domain name.
URL = Request.ServerVariables ("URL") ' Gets the current URL.
if InStr (Domain, "www") = 0 then
URL = "http://www." & Domain & URL ' Concatenates the URL to the domain
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", URL
end if
Response.Write Domain & URL ' You can remove this if you want. This just adds a check at the end.

That should do it.

Try it here:

http://searchenginefriendlylayouts.com/test_domain.asp (I intentionally removed the www).

Emark2009
04-26-2006, 04:06 PM
Hello Adam,

thanks for the script. i implemented it and it gives back the correct server header, without help of my host.

just one remark:
http://visitnatalbrazil.com redirects to http://www.visitnatalbrazil.com/index.asp and not to http://www.visitnatalbrazil.com/
Is this OK regarding the passing through of linkpopularity to http://www.visitnatalbrazil.com/ ?

thanks again for the help.

Emark2009
11-04-2006, 09:51 PM
Code:
Dim Domain, URL
Domain = Request.ServerVariables ("HTTP_HOST") ' Gets the domain name.
URL = Request.ServerVariables ("URL") ' Gets the current URL.
if InStr (Domain, "www") = 0 then
URL = "http://www." & Domain & URL ' Concatenates the URL to the domain
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", URL
end if
Response.Write Domain & URL ' You can remove this if you want. This just adds a check at the end.

Can anyone give me exact the same code for PHP?