【发布时间】:2017-05-27 20:40:10
【问题描述】:
这是我想要完成的:
http://example.com/real-estate/?group=rentals 需要去 http://example.com/real-estate/rentals
这是我的 .htaccess 中不起作用的内容:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/real-estate/ [NC]
RewriteCond %{QUERY_STRING} ^group=rentals
RewriteRule (.*) http://example.com/real-estate/rentals/? [NC,R=301,L]
</IfModule>
【问题讨论】:
-
这很不寻常...通常人们希望重定向相反。所以你传入的http请求真的是
http://example.com/real-estate/?group=rentals,可见的URL应该改为http://example.com/real-estate/rentals? 真的吗? -
没错。
-
RewriteCond 进行部分匹配,您是否尝试过不使用
^?另外,为什么要在 RewriteRule 中放置另一个??
标签: apache .htaccess http mod-rewrite web