dibs
dibs

Reputation: 137

Redirect *.htm to *.php

I am trying find out how to redirect all traffic on a website from any .htm address to a .php version of the page. I am hoping it will be a .htaccess rule but I have not been able to find anything that quite fits for me yet and I am not the greatest with .htaccess.

Any help greatly appreciated.

Upvotes: 3

Views: 3321

Answers (2)

Amit Verma
Amit Verma

Reputation: 41249

RewriteEngine on

RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
RewriteRule ^ /%1.php [NC,L,R]

This will redirect file.html to file.php without causing an infinite looping error.

Upvotes: 0

Marcus Whybrow
Marcus Whybrow

Reputation: 20008

This will do the job in your .htaccess file:

RedirectMatch 301 (.*)\.htm$ $1.php

Upvotes: 8

Related Questions