sbaaaang sbaaaang - 1 year ago 108
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)

Answer Source

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]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download