Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
重定向过多错误(.htaccess-help-required)_.htaccess - Fatal编程技术网

重定向过多错误(.htaccess-help-required)

重定向过多错误(.htaccess-help-required),.htaccess,.htaccess,假设有一个文件about.phpabc.com。 在.htaccess文件中,我有重写规则^about\us/?$about.php。 当在url中输入abc.com/about_us时,about.php将被永久加载。 abc.com/about.php也可以从url加载 我需要工作。当有人在url中键入abc.com/about.php时,它应该被301重定向到abc.com/about\us 我试过使用Redirect 301/about.php\u us,但没有成功 请在这方面帮助我。您

假设有一个文件about.phpabc.com。 在
.htaccess
文件中,我有
重写规则^about\us/?$about.php
。 当在url中输入
abc.com/about_us
时,about.php将被永久加载。
abc.com/about.php
也可以从url加载

我需要工作。当有人在url中键入
abc.com/about.php
时,它应该被301重定向到
abc.com/about\us

我试过使用
Redirect 301/about.php\u us
,但没有成功


请在这方面帮助我。

您不需要查看您的.htaccess文件,而是需要使用PHP来完成此操作

索引页的示例如下:

if($_SERVER['REQUEST_URI'] == '/index.php') header("Location: http://".$_SERVER['HTTP_HOST']."/");
对于您特别要求的关于页面:

if($_SERVER['REQUEST_URI'] == '/about.php') header("Location: http://".$_SERVER['HTTP_HOST']."/about_us");

这些应该放在PHP文件顶部附近,任何会话管理的下面。

感谢您的回复。但我需要做301重定向。需要避免重复内容的搜索引擎优化。