Return to Snippet

Revision: 8953
at October 14, 2008 21:04 by neal_grosskopf


Initial Code
'301 Redirect - URL Must Contain www.domain.com
CorrectDomain = "www.domain.com"
DefaultPage = "/index.asp"
QueryStrings = request.ServerVariables("QUERY_STRING")
URL = request.ServerVariables("URL")
	
if instr(request.ServerVariables("SERVER_NAME"),CorrectDomain) = 0  then
    
    if QueryStrings <> "" then
        QueryStrings = "?" &amp; QueryStrings
    end if
   
    if instr(URL,DefaultPage) then
        URL = replace(URL,DefaultPage,"/")
    end if
   
    response.Status = "301 Moved Permanently"
    response.AddHeader "Location","http://" &amp; CorrectDomain &amp; URL &amp; QueryStrings
    response.End
       
end if

Initial URL
http://www.nealgrosskopf.com/tech/thread.asp?pid=22

Initial Description
Learn how to create a 301 redirect for domain or home variations to improve your websites' search engine optimization.

Initial Title
How To Create A 301 Redirect For Domains Or Home Page Variances

Initial Tags
ASP

Initial Language
ASP