Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/245.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将*.htm重定向到*.php_Php_Html_Apache_.htaccess - Fatal编程技术网

将*.htm重定向到*.php

将*.htm重定向到*.php,php,html,apache,.htaccess,Php,Html,Apache,.htaccess,我正在尝试找出如何将网站上的所有流量从任何.htm地址重定向到该页面的.php版本。我希望这将是一个.htaccess规则,但我还没有找到任何适合我的规则,我也不是.htaccess最棒的 非常感谢您的帮助。这将完成.htaccess文件中的工作: RedirectMatch 301 (.*)\.htm$ $1.php 这将重定向file.html到file.php,而不会导致无限循环错误 RewriteEngine on RewriteCond %{THE_REQUEST} /([^.]+

我正在尝试找出如何将网站上的所有流量从任何.htm地址重定向到该页面的.php版本。我希望这将是一个.htaccess规则,但我还没有找到任何适合我的规则,我也不是.htaccess最棒的


非常感谢您的帮助。

这将完成.htaccess文件中的工作:

RedirectMatch 301 (.*)\.htm$ $1.php
这将重定向file.htmlfile.php,而不会导致无限循环错误

RewriteEngine on

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