Redirect * .htm to * .php

I am trying to figure out how to redirect all traffic to a website from any .htm address to a .php version of a page. I hope this will be the .htaccess rule, but I could not find anything that works for me, but I am not the best with .htaccess.

Any help is greatly appreciated.

+3
source share
2 answers

This will do the job in the .htaccess file:

RedirectMatch 301 (.*)\.htm$ $1.php
+9
source
RewriteEngine on

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

This will redirect file.html to file.php without causing an endless loop error.

0
source

Source: https://habr.com/ru/post/1783772/


All Articles