Reply to topic
301 Permanent Redirect via ASP
Josh
Forum Regular

Joined: 01 Apr 2004
Posts: 1029
Location: Felton, Delaware
Reply with quote
Hey all...

Just had a customer call stating that they wanted us to perform a 301 redirect for all of their pointed domains. This is not a problem as long as you have the same number of unique sites in IIS to perform the redirect. His reasoning is that certain search engines (Yahoo!, not Google) penalize the results for sites when they appear numerous times from different domains to the same IP address via a standard domain pointer.

Well, it is against Hostmysites policy and TOS (Terms of Service) to provide the equivilent of more than one site without it being paid for. So as far as this goes we cannot perform this for you.

HOWEVER... you can do this for you and it works wonderfully!!! Via the wonders of ASP we can modify the headers to state that a 301 Permanent Redirect is occuring... So here's the code for anybody else interested...

Code:
dim safeURL

'***** ONLY CHANGE THE LINE BELOW *****
safeURL = "YOUR_DOMAIN_NAME_HERE.com" 'domain name WITHOUT the www. prefix
'***** ONLY CHANGE THE LINE ABOVE *****

dim requestedURL
dim requestedWithPre
dim pre
dim sendTo

pre = "www."

requestedURL = LCase(Request.ServerVariables("SERVER_NAME"))

If InStr(1, requestedURL, "www.", 1) = 1 Then requestedWithPre = True

If (requestedURL <> safeURL) AND (requestedURL <> pre & safeURL) Then
   
   sendTo = "http://"
   
   If requestedWithPre Then
      sendTo = sendTo & pre & safeURL
   Else
      sendTo = sendTo & safeURL
   End If
   
   Response.Status = "301 Moved Permanently"
   Response.AddHeader "Location", sendTo
   
End If
Josh Prewitt


Joined: 24 Jun 2004
Posts: 13
Reply with quote
Thanks for that, any tip I can get for search engine placement is certainly worth a look!
301 Permanent Redirect via ASP
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic