Forum Moderators: phranque
I copied the entire code I use from one site, changed the web address and put it on my new site.
I isn't working though on the new site.
What am I doing wrong?
AddType text/html .shtml .html
AddHandler server-parsed .shtml .html
RewriteEngine on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
RewriteRule ^index\.html$ http://www.example.co.uk/ [R=301,L]
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.co.uk [NC]
RewriteRule ^(.*)$ http://www.example.co.uk/$1 [L,R=301]
AddHandler server-parsed .html
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
[edited by: jdMorgan at 2:10 pm (utc) on Sep. 16, 2007]
[edit reason] example.co.uk [/edit]
You've got two copies of "RewriteEngine on" in there, and the Options statement should go at the top of the rewrite code -- If you need it, and if it's allowed.
Basically, you must have Options +FollowSymLinks or Options +SymLinksIfOwnerMatch set in either your server configuration file or in your .htaccess file. Otherwise, you cannot use mod_rewrite.
However, some hosts will set one of those options for you, but not allow you to change it. So as Dilly observes, you can indeed get an error if you try to change Options but are not allowed by your host to do so.
The mod_rewrite part of your code should look like this:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
RewriteRule ^index\.html$ http://www.example.co.uk/ [R=301,L]
RewriteCond %{HTTP_HOST} ^example\.co\.uk [NC]
RewriteRule (.*) http://www.example.co.uk/$1 [L,R=301]
Jim
[edited by: jdMorgan at 5:31 pm (utc) on Sep. 15, 2007]
Options +FollowSymLinks
RewriteEngine on RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
RewriteRule ^index\.html$ http://www.example.co.uk/ [R=301,L]
RewriteCond %{HTTP_HOST} ^example\.co\.uk [NC]
RewriteRule (.*) http://www.example.co.uk/$1 [L,R=301]
I've got various sites with this host and use Options with all the other sites so cant think why the above shouldn't work.
Any clues?
Thanks for your suggestions so far.
The point is to avoid changing URLs, because it is URLs, not pages and not sites, that have PageRank. If you change the URLs, you throw away lots of inbound links, bookmarks, and loyal visitors who type your URLs from memory... While 301 redirects can recover some of this 'accrued value,' it often takes a long time.
Jim