Php htaccess 301重定向无法正常工作
我已经通过htaccess重写了URL,现在我想将该URL重定向到另一个URLPhp 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
下面是我的重写规则,我将其用作短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
此代码正在运行,但我遇到了问题
当我打开URLhttp://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]