user920515
user920515

Reputation: 11

RewriteRule issues in .htaccess file

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

Answers (1)

gview
gview

Reputation: 15371

You are already rewriting any directory to /dir.html

RewriteRule ^([^\.]+)$ $1.html [NC,L]

Upvotes: 1

Related Questions