views:

86

answers:

1

I want to redirect all requests for index.html|php|php5 to http://www.domain.co.uk/ using mod_rewrite and I've copied the code from a book on search engine optimization with PHP verbatim, then added in the php5 option, but it isn't working. This is my complete .htaccess file:

RewriteEngine On

#translate any .html ending into .php5
RewriteRule ^(.*)\.html$ /$1\.php5

RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php5|php|html)\HTTP
RewriteRule ^(.*)index\.(php5|php|html)$ /$1 [R=301,L]

#change / for ?
RewriteRule ^(.*)\.html/(.*)$ /$1\.html?$2

#strip .html from search res page
RewriteRule ^(.*)search/(.*)$ /$1search_results\.html/search=$2

#translate product details link from search res page
RewriteRule ^products/(.*)/(.*)/(.*)$ /product_details.php5?category=$1&title=$2&id=$3 [L]

#Translate products/psorisis/chamomile-skin-cream-P[x] to productview.php5?id=1
RewriteRule ^products/.*-P([0-9]+) /productview.php5?id=$1 [L]

I dunno what's wrong with that, and the rest works fine and dandy. Anyone have any thoughts?

+2  A: 

I think it's because your RerwriteCond ends with \HTTP.

Change it to:

RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php5|php|html)
RewriteRule ^(.*)index\.(php5|php|html)$ /$1 [R=301,L]

If you want to match the HTTP of THE_REQUEST then put a space there

RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php5|php|html)\ HTTP
RewriteRule ^(.*)index\.(php5|php|html)$ /$1 [R=301,L]
seth
so close, yet so far away. cheers, mate
Nothing like a second set of eyes!
seth