It appears you have not yet registered with our community. To register please click here...


301 Redirect on windows server

This is a discussion on 301 Redirect on windows server within the Coding Tutorials forums. Topic: If you have a dynamic ASP site and your Windows IIS host won't allow you to do the server-...


Reply
 
Postbit Seperator LinkBack Thread Tools Postbit Seperator Search this Thread Postbit Seperator Display Modes
Old 04-27-2008, 03:09 AM   #1 (permalink)
Jay
 
Jay's Avatar
 
Status: Administrator
Join Date: Feb 2007
Posts: 175
Trader Rating: (0)
Jay is on a distinguished road
TD$: 2147484922.00
Donate
Default 301 Redirect on windows server
If you have a dynamic ASP site and your Windows IIS host won't allow you to do the server-side IIS tweak, here is the code you can add to all the ASP pages on your website:

Code:
<% Domain_Name = lcase(request.ServerVariables("HTTP_HOST")) if domain_name <> "www.example.com" Then HTTP_PATH = request.ServerVariables("PATH_INFO") QUERY_STRING = request.ServerVariables("QUERY_STRING") theURL = "http://www.example.com" & HTTP_PATH if len(QUERY_STRING) > 0 Then theURL = theURL & "?" & QUERY_STRING end if Response.Clear Response.Status = "301 Moved Permanently" Response.AddHeader "Location", theURL Response.Flush Response.End end if %>

Of course, be sure to replace domain.com with your own domain name and in lower case only.

If you use this code, I suggest you save it in a file named redirect.asp and then add to the top of each file on your site the following snippet:

Code:
<!-- #Include file="redirect.asp" -->

If you have files in sub-directories add the appropriate path info or use a fully qualified path.

Hope this helps.
Jay is offline   Reply With Quote
Table Bottom LeftTable BottomTable Bottom Right
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




Home | Site Map | Contact | Archive | Top

 

Copyright © 2007 - 2010 iTalkWebs Network

Search Engine Optimization by vBSEO 3.1.0