user2118445
user2118445

Reputation: 465

Remove .html from url through .htaccess

I am using following code in Localhost after some some apache settings it is working fine.

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

But when I upload this .htaccess file on hosting server then showing error 404. When I check online .htaccess tester it is showing "This variable is not supported: %{REQUEST_FILENAME}"

Upvotes: 1

Views: 56

Answers (1)

Rehmat
Rehmat

Reputation: 5081

This should work:

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

Upvotes: 1

Related Questions