Redirect *.htm to *.php

非 Y 不嫁゛ 提交于 2020-01-09 11:45:10

问题


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.


回答1:


This will do the job in your .htaccess file:

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



回答2:


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.



来源:https://stackoverflow.com/questions/4610973/redirect-htm-to-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!