.htaccess rewrite www to non-www and remove .html
- by lester8891
I need rewrite rules to redirect the following:
http://www. to http://
/file.html to /file
I've tried using a combination of these but each time it results in a redirect loop on one of the situations
RewriteBase /
RewriteRule ^(.*)\.html$ $1 [NC]
RewriteCond %{HTTP_HOST} ^www.domain.co.uk [NC, L]
RewriteRule ^(.*)$ http://domain.co.uk/$1 [R=301]
I figure it's probably something to do with the flags but I don't know how to fix it. Just to be clear it needs to do all these situations:
http://www.domain.co.uk to http://domain.co.uk
http://www.domain.co.uk/file.html to http://domain.co.uk/file
http://domain.co.uk to http://domain.co.uk
http://domain.co.uk/file.html to http://domain.co.uk/file
Thanks!