sbaaaang sbaaaang - 4 months ago 26
Apache Configuration Question

HTACCESS remove ext html from url

I have urls like these:

all i need is to return the same page removing ".html" so:

in case of somenthing after ".html" i need to add back slash

is there anyway to do this in htaccess?

i'm only using js and html pages (no server side languages)


Copy, paste and edit from Apache .htacces Rewrite Rule to Remove .php File Extensions

Options +FollowSymlinks -MultiViews
RewriteEngine on

# to make `/path/index.html` to /path/
RewriteCond %{THE_REQUEST} ^GET\s(.*/)index\.html [NC]
RewriteRule . %1 [NE,R=301,L]

RewriteCond %{THE_REQUEST} ^GET\s.+\.html [NC]
RewriteRule ^(.+)\.html$ /$1 [NE,R=301,L,NC]

RewriteCond %{REQUEST_URI} !\.html$ [NC]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule . %{REQUEST_URI}.html [L]