mercredi 26 août 2020

.Htaccess doesn't remove .html ending from static website url links?

I have static website uploaded on Cpanel file manager. I need to remove .html ending on every webpage.

For example i want www.example.com/something instead of www.example.com/something.html

So i created .htaccess file and tried 2 different codes which didn't work:

  1. try didn't work:
RewriteBase /

# handle trailing slashes (if not a directory)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [R,L]

# rewrite rule that internally adds the .html extension
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+[^/])$ $1.html
  1. try didn't work either:
RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]

Is it something wrong with my code inside .htaccess file ?

I uploaded .htaccess file in same main folder where every .html and index file is.

Do i have to manually remove .html from every webpage seperately? But if i do that im having trouble coding because it is text file.




Aucun commentaire:

Enregistrer un commentaire