繁体   English   中英

带有URL中的变量的htaccess的重定向301

[英]redirection 301 with htaccess with variables in url

我在论坛上搜索了答案,但没有为我工作。

我已经使用Wordpress重建了一个网站,并希望保留旧的网址。

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

nwe网址: https://website.com/product/the-new-url-of-play-bingo-40/ ://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]

任何人?

您无需使用查询字符串中的任何内容,因此无需使用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/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM