skip to Main Content

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?

2

Answers


  1. 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.

    Login or Signup to reply.
  2. 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">
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search