Saturday, 15 September 2012

.htaccess - What is the regex for anything.com/anypage.html to redirect to anything.com/anypage -



.htaccess - What is the regex for anything.com/anypage.html to redirect to anything.com/anypage -

in htaccess file right regex matching following

anything.com/anypage.html redirect anything.com/anypage

so allow html stripped off urls.

thanks

here 1 way it

options +followsymlinks rewriteengine on rewritebase / rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} ^/(.*)/?([^/]+)\.html [nc] rewriterule .* %1%2 [r=301,l]

redirects permanently

http://example.com/filename.html or

http://example.com/folders/filename.html

to:

http://example.com/filename or

http://example.com/folders/filename

effectively removing extension .html fom url

for silent mapping, remove r=301 [r=301,l]

regex .htaccess

No comments:

Post a Comment