Getting rid of .html extension in URL
Hi,
I tried to remove .html file extension from URL bar while usine .htaccess but I led to error 500.
The code I tried in .htaccess file:
How can I get rid of .html file extension in url bar? Thanks!
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]How can I get rid of .html file extension in url bar? Thanks!
-
This should work - RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.html [NC,L] 0 -
Try this, RewriteRule ^(.*)\.html$ /$1 [R=301,L] 0 -
thanks, both solutions seemed to work but they both made the loading from one url to another really slow, I also have a few 301 redirects but they don't seem to intervene with given codes. How could I solve this long loading time issue? 0 -
As far as I am aware none of those rewrite rules should have caused slow loading times. If you don't have access to WHM (which as a website owner I assume you do not) you can check cPanel>>Metrics>>Errors to see the last 300 error log messages relating to your account's domains which might be helpful for you. Otherwise I'd suggest working with your hosting provider to identify the cause of the delay. 0 -
This should work - RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.html [NC,L]
This rule breaks cPanel login for me. If you are using it make sure to exclude the cPanel subdomain.0
Please sign in to leave a comment.
Comments
5 comments