cancel
Showing results for 
Search instead for 
Did you mean: 

301 redirect for search engine optimisation

Mattallyc
Newbie
Posts: 8
Registered: 25-10-2010

301 redirect for search engine optimisation

Hi everyone,
I'm trying to put in place a 301 redirect so that web pages to http://tecker.co.uk get redirected to http://www.tecker.co.uk by using a .htaccess file I've created and put in the root of my webspace.
There are two examples I've found on this forum:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^tecker\.co\.uk [NC]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)$ http://www.tecker.co.uk/$1?%1 [R=301,L]

and

RewriteEngine on
RewriteCond %{HTTP_HOST} ^tecker.co.uk [NC]
RewriteRule ^(.*)$ http://www.tecker.co.uk/$1 [L,R=301]

The first one from http://community.plus.net/forum/index.php/topic,71144.0.html gives me a server error 500.
The second one from http://community.plus.net/forum/index.php/topic,72510.0.html does nothing, no error, no redirect.
Does anyone have any idea why it's not working?
Thanks in advance,
Matt.
2 REPLIES
Mattallyc
Newbie
Posts: 8
Registered: 25-10-2010

Re: 301 redirect for search engine optimisation

SOLVED
After some more research it turned out there were two copies of the website, one at ftp.plus.net and another at cshell.plus.net
Pinging both sites returned two different ip addresses.
I put the redirect on the ftp version (the non-www) and it worked, I guess by putting the redirect on the other site it caused a loop (and therefore an error) as it would have been redirecting to itself.
If you're interested I used the second version of the code above.
Cheers,
Matt.
Superuser
Superuser
Posts: 9,039
Thanks: 490
Fixes: 43
Registered: 06-04-2007

Re: 301 redirect for search engine optimisation

Glad to hear you've solved this. The ftp site is homepages (with an htdocs folder) whereas cshell is ccgi (which is entered at /). I couldn't see any reason why the second version wouldn't work on homepages or ccgi.
On cshell/ccgi the first version of the code would give a server Error 500 because the Options line is not permitted (security issue). Without that it would probably have done nothing just as the second one did.
The reason for nothing being done (as previously set up) is that there is nothing to do; any cshell/ccgi call would have the hostname starting with www so the condition will fail. Wink
David