2016-07-06 137 views
0

与变量htaccess的我搜索论坛上的答案,但并没有为我工作。重定向301在网址

我有使用Wordpress重建一个网站,并希望保持旧网址。

旧网址: /bingo/play-bingo-40/review?reviews_id=16

NWE网址: https://website.com/product/the-new-url-of-play-bingo-40/

我已经试过这样:

RewriteCond %{QUERY_STRING} ^reviews_id=([^&]+) [NC] 
RewriteRule ^bingo/play-bingo-40/review https://website.com/product/the-new-url-of-play-bingo-40/? [R=301] 

任何一个?

+0

试试这个重定向301 /宾果游戏/宾果游戏-40 /评论?reviews_id = 16 https://website.com/product/the-new-url-of-play-bingo -40/ – unixmiah

+0

您可以使用简单的301重定向插件。 https://wordpress.org/plugins/simple-301-redirects/访问这个网站并阅读文档并使用这个插件。 – WisdmLabs

+0

谢谢,但已经尝试过,不起作用。 –

回答

0

你不从查询字符串中使用任何东西,所以你不需要用RewriteCond捕捉到。你似乎使用请求URL的一部分,所以你必须抓住这一个

RewriteRule ^bingo/(.+?)/review https://example.com/product/the-new-url-of-$1/? [R,L] 

要了解更多关于mod_rewrite的一般和正则表达式特别,看到http://httpd.apache.org/docs/current/rewrite/intro.html。正则表达式的另一个很好的参考是http://www.regular-expressions.info/