3

I'm helping a client migrate an old site which used .html extension at the end of the web address to a properly named URL structure. I want to do a redirect for all URLs that end in .html to the homepage.

I tried this but it didn't work:

RewriteRule ^(.*)\.html$ $1http://domain.org [NC]
Book Of Zeus
  • 49,509
  • 18
  • 174
  • 171
spike5792
  • 75
  • 2
  • 2
  • 5

3 Answers3

3

You can use sometihing like this:

  RewriteEngine On 
  RewriteBase /
  RewriteCond %{SCRIPT_FILENAME} !-f
  RewriteRule ([^/]+)\.html$ index.php?page=$1 [L,NC]

or for permanent redirect

  RewriteEngine On 
  RewriteBase /
  RewriteCond %{SCRIPT_FILENAME} !-f
  RewriteRule (.*)\.html$ / [R=301,NC,L]
Book Of Zeus
  • 49,509
  • 18
  • 174
  • 171
3

Something like this should fit you needs:

RewriteEngine On 
RewriteBase /
RewriteRule (.*)\.html$ / [QSA,R=301,NC,L]
Olivier Pons
  • 15,363
  • 26
  • 117
  • 213
0

Your question is not very clear but just based on your code I think this will work for you:

RewriteRule \.html$ http://domain.org/? [R,L,NC]

This will redirect every URL ending with .html to http://domain.org/ even stripping out any query parameter in the original URI.

anubhava
  • 761,203
  • 64
  • 569
  • 643