Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

htaccess redirect all html files

Can someone write me a rule that will redirect all requests for

http://www.example.com/some_page.html

to

http://www.example.com/some_page/

Thank you!!

like image 955
Aaron Avatar asked Sep 24 '09 17:09

Aaron


2 Answers

If you really want to redirect requests of /some_page.html to /some_page/:

RewriteRule (.+)\.html$ /$1/ [L,R]

But if you want to reverse (redirect requests of /some_page/ to /some_page.html):

RewriteRule (.+)/$ /$1.html [L,R]

For a permanent redirect, use R=301 instead of R. And for just an internal rewrite, use the rule without R flag.

like image 128
Gumbo Avatar answered Nov 17 '22 07:11

Gumbo


Do you mean:

RedirectMatch 301 (.*)\.html$ http://www.example.com$1/
like image 23
jao Avatar answered Nov 17 '22 08:11

jao