6 Oct 2015

Ht access Redirect

<IfModule mod_rewrite.c>
  RewriteEngine on
## hide .html extension
# To externally redirect /dir/foo.html to /dir/foo
  RewriteCond %{REQUEST_METHOD}  !=POST
  RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
  RewriteRule ^ %1 [R=301,L,NC]

## To internally redirect /dir/foo to /dir/foo.html
  RewriteCond %{REQUEST_FILENAME}.html -f
  RewriteRule ^ %{REQUEST_URI}.html [L]
 
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule .* 404.html [L]
</IfModule>

No comments:

Post a Comment