Forum Moderators: phranque

Message Too Old, No Replies

Redirect .htm to .html files

Redirect .htm to .html files using rewrite rule

         

MattyUK

6:27 pm on Mar 15, 2007 (gmt 0)

10+ Year Member



I'm looking for a way to redirect all requests for .htm files to .html files. It should preserve any query strings.

This is to catch users typing file.htm and redirect them to file.html. If file.html doesn't exist then the normal 404 is desired.

I started with this rule:


RewriteRule ^(.*\.htm)$ $1l [R=301,NC,L]

But since this doesn't work the way I'd hoped, I could use a pointer, if anyone will be so kind.

Regards,
Matt

Gahhh....
I must have been asleep. I need to specify the full url or the site root for the output.

RewriteRule ^(.*\.htm)$ /$1l [R=301,NC,L]

or
RewriteRule ^(.*\.htm)$ http://www.adomain.com/$1l [R=301,NC,L]

Comments, still welcome, if there is the need.

[edited by: MattyUK at 6:57 pm (utc) on Mar. 15, 2007]

milanmk

7:34 pm on Mar 15, 2007 (gmt 0)

10+ Year Member



This should work fine.

RewriteEngine on
RewriteRule ^(.*\.htm)$ [domain.com...] [R=301,NC,L]

Milan