Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.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
Php htaccess仅重定向301父url_Php_.htaccess_Redirect_Mod Rewrite - Fatal编程技术网

Php htaccess仅重定向301父url

Php htaccess仅重定向301父url,php,.htaccess,redirect,mod-rewrite,Php,.htaccess,Redirect,Mod Rewrite,我在我的网站上使用干净的URL。我已更改其中一页的路径。原始路径是: mywebsite.com/projects 新的路径是: mywebsite.com/what-we-do 我尝试添加301重定向,如下所示: Redirect 301 /projects /what-we-do 然而,这对该页面有效,但也意味着所有以/projects/xxx开头的子页面都被转发到/what-we-do/xxx,这是我不希望发生的。我希望项目子页面不重定向 使用重定向匹配而不是重定向 使用正则表达式

我在我的网站上使用干净的URL。我已更改其中一页的路径。原始路径是:

mywebsite.com/projects 
新的路径是:

mywebsite.com/what-we-do
我尝试添加301重定向,如下所示:

Redirect 301 /projects /what-we-do

然而,这对该页面有效,但也意味着所有以
/projects/xxx
开头的子页面都被转发到
/what-we-do/xxx
,这是我不希望发生的。我希望项目子页面不重定向

使用
重定向匹配
而不是
重定向

使用正则表达式并允许指定精确匹配的

RedirectMatch 301 /projects$ /what-we-do
$
是“结束”的正则表达式)