Awesome .htaccess for having pretty urls with static html files

paincake

Power Member
Joined
Aug 18, 2010
Messages
721
Reaction score
3,123
Save this as .htaccess and put it in your website root folder:
Code:
RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*[^/]$ %{REQUEST_URI}/ [L,R=301]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)/$ $1.html [L]

These rules will automatically redirect urls to corresponding html files.

For example, if your visitors go to:

www.yoursite.com/page1-test/

they will see the contents of page1-test.html
 
Top