【发布时间】:2020-02-14 05:14:00
【问题描述】:
我正在尝试进行 301 重定向。但它不会被重定向。
我的旧网址:https://www.example.com/category.php?filter=Short%20Term%20Renting
我的新网址:https://www.example.com/services/short-term-renting
我在 .htaccess 中的代码:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^([^&]&)*filter=Short%20Term%20Renting(&|$)
RewriteRule ^category.php/services$ /short-term-renting? [L,R=301]
我用这个链接“301 Redirecting URLs based on GET variables in .htaccess”引用了
【问题讨论】:
-
bunch\.of在example.com/category.php?filter=Short%20Term%20Renting 中在哪里? -
category.php/services也不属于旧网址。 -
@04FS category.php/services 是新 URL 的一部分
-
是的,但是 RewriteRule 的第一部分是您要匹配的 old URL 路径。
-
我点击了这个链接“stackoverflow.com/questions/871511/…”