Timmy863
Timmy863

Reputation: 7

Rewrite URL to remove `.html` extension

I am trying to remove the .html extension on my website URL but nothing seems to work. <Website>. I have made a .htaccess file and put in the following:

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

AND

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

but I find that nothing seems to work. Any ideas?

Upvotes: 0

Views: 604

Answers (2)

Denise
Denise

Reputation: 29

Use this meta and then upload your files into the web root without the .html extension

<meta http-equiv="content-type" content="text/html; UTF-8">

Upvotes: 0

lod
lod

Reputation: 1100

Your rewrite implementation is fine.

You most likely don't have htaccess AllowOverride directives enabled, or possibly mod_rewrite is not switched on.

If you have access to the server configuration and logs it is better to put the rewrite directives in the server configuration file. It is faster, cleaner and avoids possible AllowOverride issues. The logs should show exactly what is happening, you can temporarily enable verbose mod_rewrite logging with:

LogLevel alert rewrite:trace3

If you don't have access to the server configuration and logs then you will need to contact your provider. Without access to those it is impossible to solve the problem.

Upvotes: 1

Related Questions