Reputation: 11
I am trying to create a 301 redirect for my .html extensions but every RewriteRule I attempt creates an endless loop - my current htaccess file is below.
As an example, our contact page is accessible through both "/contact.html" and "/contact" but I would like "contact.html" to have a 301 redirect to "/contact".
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
RewriteCond %{HTTP_HOST} ^pulseconsulting\.co.nz$ [NC]
RewriteRule ^(.*)$ http://www.pulseconsulting.co.nz/$1 [R=301,L]
Upvotes: 1
Views: 178
Reputation: 15371
You are already rewriting any directory to /dir.html
RewriteRule ^([^\.]+)$ $1.html [NC,L]
Upvotes: 1