1

I would like to remove the .html part from the URL's that are shown in the URL.

I was able to fix that with:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f

That works! :)

But now I got double URL's of every page

  • page1
  • page1.html
  • etc.

I don't want a 404-error on the .html pages so I would like to redirect this to the page without .html (301-redirect). But i have no idea to do that in the .htaccess

I tried:

RewriteRule ^(.*)\.html$ /$1 [L,R=301]

But doesn't work --> .html files are still working

Anybody that could help me? :) Thanks!

ps. I really can't write .htaccess, please answer that I could copy-paste. That's a lot!

1 Answers1

0

Try this

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^([^\.]+)$ $1.html [NC,L]

ErrorDocument 404 /404 
Ruben
  • 319
  • 2
  • 14