PeterNJ
PeterNJ

Reputation: 3

.htaccess Problem to remove extensions creates subdirectory problem

I have a static html website and I am using the following code to remove the .html extension for SEO reasons:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.html [NC,L]

Problem is when I add a subdirectory /blog/ I get a 403 Forbidden error. Any help please?

Upvotes: 0

Views: 23

Answers (1)

learningtoanimate
learningtoanimate

Reputation: 934

Try this, you were missing the html condition.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html

Upvotes: 0

Related Questions