Are you a Google Analytics enthusiast?
Share and download Custom Google Analytics Reports, dashboards and advanced segments--for FREE!

www.CustomReportSharing.com
From the folks who brought you High Rankings!
More SEO Content
301 Redirects On Windows 2000 Iis
#16
Posted 25 July 2006 - 12:12 AM
Your solution is very helpful for dealing with a few pages, and helps my understanding of the situation. The developer has renamed about 100 pages (they contacted me afterwards). First, the original pages don't exist on the new server, so we'd have to create them, and then set up each of the redirects by hand. Of course, I don't have direct access to the server so I'd have to count on somebody else, which worries me.
I can build an Excel spreadsheet with a map of the redirects, and turn it into a series of ISAPI_rewrite commands. The software is $69, and the install is quick. It seems like this solution will take less time, and make it easy to modify the redirects by editing the http.ini file remotely. No administrator required.
#17
Posted 29 July 2006 - 02:03 AM
For doing 301 redirection of my site's domain.com(non www) to www.domain.com(with www), what i should use.
Code given by chrishirst or by the tips given at mcanerin's site. Which is better.
And if i want to use chrishirst's code, where i have to put it??? In head section... Probabely i think.
Edited by Mohit., 29 July 2006 - 02:10 AM.
#18
Posted 12 March 2007 - 11:38 PM
[codebox]if(Request.ServerVariables("SERVER_NAME") <> "justassociates.com") then bRedirect = true[/codebox]
I get an error back in my browser that says:
The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete
* This problem can sometimes be caused by disabling or refusing to accept
cookies.
Any ideas??
Thank You
dim pathinfo
dim bRedirect
dim MainDomain
hostname = request.servervariables("HTTP_HOST")
pathinfo = request.servervariables("PATH_INFO")
MainDomain = "www.domain.com"
if pathinfo <> "" then
if instr(lcase(pathinfo),"default.asp") > 0 or instr(lcase(pathinfo),"index.asp") > 0 or instr(lcase(pathinfo),"index.aspx") > 0 then
MainDomain = MainDomain &"/" & mid(pathinfo,2,instrrev(pathinfo,"/")-1)
else
MainDomain = MainDomain & pathinfo
end if
else
MainDomain = MainDomain & "/"
end if
if left(hostname,instr(hostname,".")) <> "www." then bRedirect = true
if bRedirect then
response.status = "301 Moved Permanently"
response.addheader "Location", "http://" & MainDomain
response.end
end if
put it at the top of every ASP page as an include every page and folder will be corrected.
Raphael, If IIS is left to it's own devices all the versions will return a 200 response so looks like duplicate sites (www & non-www).
#19
Posted 13 March 2007 - 02:56 PM
it should go in above
if left(hostname,instr(hostname,".")) <> "www." then bRedirect = true
do take note that this code does not take querystrings into account though it could be added.
#20
Posted 13 March 2007 - 05:24 PM
I had added it below that line. I'll fix it up and post back after I test
Thanks
#21
Posted 13 March 2007 - 07:34 PM
it should go in above
if left(hostname,instr(hostname,".")) <> "www." then bRedirect = true
do take note that this code does not take querystrings into account though it could be added.
hmm... I placed the new line above the line you pointed out and I am still getting the browser error when I go to the mirror domain (which would return a 200 normally if I wasn't messing with the ASP script. Here is my exact code. Any other ideas? It would appreciated.
Thank You
[codebox]<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
dim hostname
dim pathinfo
dim bRedirect
dim MainDomain
dim domain
hostname = request.servervariables("HTTP_HOST")
pathinfo = request.servervariables("PATH_INFO")
domain = Request.ServerVariables("SERVER_NAME")
MainDomain = "www.justassociates.com"
if pathinfo <> "" then
if instr(lcase(pathinfo),"default.asp") > 0 or instr(lcase(pathinfo),"index.asp") > 0 or instr(lcase(pathinfo),"index.aspx") > 0 then
MainDomain = MainDomain &"/" & mid(pathinfo,2,instrrev(pathinfo,"/")-1)
else
MainDomain = MainDomain & pathinfo
end if
else
MainDomain = MainDomain & "/"
end if
if(domain <> "justassociates.com") then bRedirect = true
if left(hostname,instr(hostname,".")) <> "www." then bRedirect = true
if bRedirect then
response.status = "301 Moved Permanently"
response.addheader "Location", "http://" & MainDomain
response.end
end if
%>[/codebox]
#22
Posted 14 March 2007 - 05:27 AM
There is no need for the second variable of domain. You should also be aware of the differences between HTTP_HOST and SERVER_NAME.
Usually both will return the same value, BUT depending on the configuration within a hosting datacentre, if it uses NAT routing or port routing through a firewall or DMZ for example, SERVER_NAME will return the routed name NOT the host header or DNS name which is the important bit from an external POV.
HTTP_HOST will return the DNS name (host header) of the server.
so instead of this;
if(domain <> "justassociates.com") then bRedirect = true
use;
However be aware that if the hostname contains "justassociates.com" anywhere (for example "abc-justassociates.com") it will fail to redirect
and of course you could use;
if(hostname <> "justassociates.com") then bRedirect = true
However this would also redirect if you were using any sub-domains.
Additional code required to handle querystrings
end if
' insert the lines below.
if request.servervariables("QUERY_STRING") <> "" then
MainDomain = MainDomain & "?" & request.servervariables("QUERY_STRING")
end if
#23
Posted 14 March 2007 - 02:00 PM
Thanks again for the input. I'll give it a go later today and post back results again.
thanks
Mike
#24
Posted 20 March 2007 - 09:39 PM
#25
Posted 24 September 2008 - 10:14 AM
#26
Posted 25 September 2008 - 06:42 AM
Yes you can.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users









