Permanent 301 redirect

in2d

Free Member
Aug 20, 2007
30
0
:| I ran a check on my site with website grader (had never heard of it before today ... but looks like a nifty little tool).

It is telling me this:
"Search engines may think www .mysite.co.uk and mysite.co.uk are two different sites.You should set up a permanent redirect (technically called a "301 redirect") between these sites. Once you do that, you will get full search engine credit for your work on these sites.

For example, www .mysite.co.uk seems to have 101 inbound links whereas mysite.co.uk has 107 inbound links. By correctly configuring a permanent 301 redirect, the search rankings might improve as all inbound links are correctly counted for the website."

Does anyone have any experience of this? I'm struggling to understand exactly what I am supposed to be doing.

Any suggestions much appreciated
 
Last edited:

in2d

Free Member
Aug 20, 2007
30
0
Upvote 0

greenwood-IT

Free Member
Oct 31, 2008
155
32
Hythe, Hampshire
Hiya,

I just checked the other thread and didn't see a quick answer for IIS/ASP, so here's my logic. If your using Apache, then the other thread covers that.

If it's IIS, then include this section in the top of one of your global include files as you'll need this on every page (you never know which page the visitor will enter your site via).

--8<-----------------------------------------------------------------
'### Correct the website URL from anything 'abnormal' ###
ThisWebsite = "www,greenwood-it,co,uk"
Requested = lcase(Request.ServerVariables("SERVER_NAME"))
If Requested <> lcase(ThisWebsite) then
URL = "h t t p ://" & ThisWebsite
ScriptName = mid(Request.ServerVariables("SCRIPT_NAME"), 2)
QueryString = Request.ServerVariables("QUERY_STRING")
If ScriptName <> "" then URL = URL & "/" & ScriptName
If QueryString <> "" then URL = URL & "?" & QueryString
Response.Status = "301 Moved Permanently"
Response.Addheader "Location", URL
Response.End
End if
--8<----------------------------------------------------------------

You'll obviosuly have to replace the 'ThisWebsite' variable with your full URL. Also line 5 will need the spaces removed from 'h t t p :' in order to make it work! (I'm going to have to pay to join this forum just so that i can include URLs :)).

This script does have a limitation in that it will redirect HTTPS/SSL connections to the insecure equivalent page, but I'll let you work that out ;)

Chat soon.
 
Last edited:
  • Like
Reactions: in2d
Upvote 0

Latest Articles