Saturday, 14 December 2013

htaccess redirect to .html/redirect requests of /some_page/ to /some_page.html



htaccess redirect to .html/redirect requests of /some_page/ to /some_page.html

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

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

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


Share:

No comments:

Post a Comment