Jump to content

asp 301 perm redirect?


spipe
 Share

Recommended Posts

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 Found this on a forum wondered what it did?

Link to comment
Share on other sites

The code checks to see that the an ASP script is hosted on a server located at safeURL. If it isn't, the script forces the browser to a display a 301 Relocation page.However, I really doubt that code is really going to be useful to you. If you're problem is just search engines penalizing your site, then you don't even need ASP at all, you can add a robots metatag to the top of your HTML page:

<meta name="robots" content="noindex,nofollow">

Otherwise, use a Robots.txt in your /root folder. See this page for a few examples.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...