0

i have a problem with my .htaccess file. I wan't to hide the file extention in my website ("website.com/index.html" to "website.com/index")

After research on internet, i found this solution for html file

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

But I don't know why, it didn't work for me :/.

My .htaccess file is on the root of my website.

ItsBursty
  • 1
  • 4
  • Do you have any other directives in your htaccess file? Add some nonsense at the top of the file; do you get an error? – MrWhite Nov 14 '21 at 22:50
  • What do you mean by "did not work?" What does `example.com/index` show? Is it the page you expect or an error? Have you changed the links in your pages to point to the new URL without an extension? Do you also want to redirect away from the URLs with extensions? – Stephen Ostermiller Nov 14 '21 at 23:10
  • I change the url in my html file to see if it redirect me to the correct url but when i go to "mypage.com/index" it show me a 404 not found. – ItsBursty Nov 15 '21 at 09:16

1 Answers1

0

You must enable allowOverride in your site's config file for the directory that contains your .htaccess file. See https://stackoverflow.com/a/63202947/8082880

Larcis
  • 134
  • 7
  • It does'nt work i have the same problem. Like before, i have a 404 error when i go to "website.com/index" :/ – ItsBursty Nov 14 '21 at 22:06