2

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


以下是我用于短 URL 的重写规则

RewriteRule ^([a-zA-Z0-9_-]+)$ modules/pages/content.php?page_url=$1 [NC,L]

这工作正常,我可以访问 URL,如..

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


现在我想将http://www.domain.com/example-pageURL 重定向到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-page

但取而代之的是。我希望它重定向到http://www.domain.com/product/features/example-page.

请帮助我解决这个问题。

4

1 回答 1

7

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

RewriteRule ^example-page$ http://www.domain.com/product/features/example-page [L,R=301]
于 2013-11-14T06:27:17.500 回答