Tue 20 Mar 2007
This assumes your default file is default.asp. If it is not default.asp, then you will need to change it. This is important to prevent endless looping.
Change example.com on line 7 to your domain name. This will do a permanent redirect to the non-www version of your domain. Place this at the top of your file.
<%
PATH_INFO = lcase(Request.servervariables(”PATH_INFO”))
if PATH_INFO = “/default.asp” then
PATH_INFO = “”
end if
HTTP_HOST = lcase(Request.servervariables(”HTTP_HOST”))
if instr(HTTP_HOST, “www.”) = 1 then
newurl = “http://example.com” & PATH_INFO
Response.Status = “301 Moved Permanently”
Response.AddHeader “Location”, newurl
Response.End
end if
%>
So why would I want to do this?
- If you prefer to use the non-www version of your site. (http://example.com)
- Consistent URL referencing is a basic key to good SEO (search engine optimization).