0

I have HTML website hosted under Apache. Following htaccess added to redirect all the http calls to https and hide the extension from URL. I have following pages in it

Home page - example.com <- index.html
About  - example.com/about <- about.html
Contact - example.com/contact <- contact.html
404 - example.com/404 <- 404.html

htaccess

AddType application/x-httpd-php .html .htm
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /$1 [L,R=301]
ErrorDocument 404 https://www.example.com/404.html

But if we call a page directly as https://example.com/contact.html this will render with .html extension itself(same as example.com/contact.html), it supposed to be https://www.example.com/contact.

Anyone can help to solve this confusion?

Aadi
  • 6,959
  • 28
  • 100
  • 145
  • Possible duplicate of [How to remove php extension and also redirect extensions to no extension form](https://stackoverflow.com/questions/33021181/how-to-remove-php-extension-and-also-redirect-extensions-to-no-extension-form) – VuoriLiikaluoma Aug 26 '19 at 12:35
  • This `htaccess` code should work as expected. Clear your browser cache and try again. – Gary Thomas Aug 26 '19 at 16:07

0 Answers0