Skip to main content

Getting rid of .html extension in URL

Comments

5 comments

  • Cake
    This should work - RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.html [NC,L]
    0
  • nixuser
    Try this, RewriteRule ^(.*)\.html$ /$1 [R=301,L]
    0
  • chroneas
    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
  • cPanelLauren
    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
  • gramzon
    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.