Troubleshoot .html URL extension using .htaccess

Trying to remove .html extensions from a site using .htaccess. So for example: www.mysite.com/charts.html will become www.mysite.com/charts

The following script file is in the .htaccess file:

RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)\.html$ /$1 [L,R=301] 

But when the URL containing the .html extension is entered in the browser, it shows a 403 Forbidden error. Any help would be appreciated.

+4
source share
1 answer

I found this solution elsewhere:

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

Sources: 1) http://www.catswhocode.com/blog/10-useful-htaccess-snippets-to-have-in-your-toolbox 2) http://eisabainyo.net/weblog/2007/08/19 / removing-file-extension-via-htaccess /

+6
source

Source: https://habr.com/ru/post/1413424/


All Articles