Reputation: 11
I seem to have canonical problems - duplication of my site's index page is confusing google apparently.
So I thought I'd try the .htaccess route, I have been advised to use the following code
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^alexgreen.co.uk
RewriteRule (.*) http://www.alexgreen.co.uk/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /index.htm HTTP/
RewriteRule ^index.html$ http://www.alexgreen.co.uk/ [R=301,L]
But all I get is the following message:
"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request."
Could I be trying something on the wrong type of server? It is a linux based server hosted with 1and1 (I think) But it does allow php, mysql, perl.
Does anyone have any ideas or should I try to do things differently?
Thanks in advance..
Upvotes: 1
Views: 106
Reputation: 4271
This is the script i usually use
RewriteRule On +FollowSymLinks
#add www
RewriteCond %{HTTP_HOST} ^(alexgreen\.co\.uk)(:80)? [NC]
RewriteRule ^(.*)$ http://www.alexgreen.co.uk/$1 [R=301,L]
# Hide index.php
RewriteCond %{THE_REQUEST} \/index.html\ HTTP [NC]
RewriteRule (.*)index.html$ /$1 [R=301,L]
idk if you want index.html or index.htm because that will also cause problems not specify which to go with. in your scrip you used both.
Upvotes: 0
Reputation: 143916
This line here:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /index.htm HTTP/
needs to have all the spaces escaped, otherwise mod_rewrite will think that ^[A-Z]{3,9}
/index.htm
and HTTP/
are all different parameters:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.htm\ HTTP/
Upvotes: 1