3

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.

dibs
  • 137
  • 2
  • 8

2 Answers2

8

This will do the job in your .htaccess file:

RedirectMatch 301 (.*)\.htm$ $1.php
Marcus Whybrow
  • 18,990
  • 8
  • 68
  • 89
0
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.

Amit Verma
  • 39,545
  • 18
  • 87
  • 107