Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.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重定向无法正常工作_Php_Apache_.htaccess_Mod Rewrite_Redirect - Fatal编程技术网

Php htaccess 301重定向无法正常工作

Php htaccess 301重定向无法正常工作,php,apache,.htaccess,mod-rewrite,redirect,Php,Apache,.htaccess,Mod Rewrite,Redirect,我已经通过htaccess重写了URL,现在我想将该URL重定向到另一个URL 下面是我的重写规则,我将其用作短URL RewriteRule ^([a-zA-Z0-9_-]+)$ modules/pages/content.php?page_url=$1 [NC,L] 这是很好的工作,我可以访问的网址像 http://www.domain.com/example-page 现在我想重定向http://www.domain.com/example-pageURL到http://www.dom

我已经通过htaccess重写了URL,现在我想将该URL重定向到另一个URL


下面是我的重写规则,我将其用作短URL

RewriteRule ^([a-zA-Z0-9_-]+)$ modules/pages/content.php?page_url=$1 [NC,L]
这是很好的工作,我可以访问的网址像

http://www.domain.com/example-page

现在我想重定向
http://www.domain.com/example-page
URL到
http://www.domain.com/product/features/example-page

我的htaccess重定向代码是

redirect 301 /example-page http://www.domain.com/product/features/example-page
此代码正在运行,但我遇到了问题

当我打开URL
http://www.domain.com/example-page
它重定向到
http://www.domain.com/product/features/example-page?page_url=example-第页

但事实并非如此。我希望它重定向到
http://www.domain.com/product/features/example-page


请帮助我解决这个问题。

您需要坚持使用mod_rewrite,不要将mod_rewrite指令与mod_alias指令混合使用(
重定向301
)。在将规则路由重写到
content.php
之前,添加:

RewriteRule ^example-page$ http://www.domain.com/product/features/example-page [L,R=301]