VibrationPositive
VibrationPositive

Reputation: 410

What is the simplest way to remove .html with an htaccess file?

So I have a been trying a lot of different htaccess codings to clean up my url

but am not even able to simply remove .html without something going wrong

Code Im using: RewriteCond %{REQUEST_FILENAME}.html -f RewriteRule ^(.+)/$ $1.html [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*[^/]$ %{REQUEST_URI}/ [L,R=301]

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*[^/]$ %{REQUEST_URI}/ [L,R=301]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)/$ $1.html [L]

CODE Im hoping to clean up:

 <area shape="poly" coords="3,612,78,557,118,627,5,708"     href="collabwitus.html" />

Little new to htaccess and would love some help!

I am doing everything from file manager via hostgator so framing an answer in a more step by step version using file manager would be great!

Upvotes: 1

Views: 143

Answers (3)

VibrationPositive
VibrationPositive

Reputation: 410

This code worked for me:

RewriteEngine On

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

Upvotes: 0

Mohammed Elhag
Mohammed Elhag

Reputation: 4302

Put the following code :

RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+(.*?/)?(?:index)?(.*?)\.html[\s?/] [NC]
RewriteRule ^ /%1%2 [R=302,L,NE]

Upvotes: 1

meidanisalekos
meidanisalekos

Reputation: 51

Try this:

RewriteEngine On

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

Upvotes: 0

Related Questions