为 /
具有查询字符串的任何请求导致404被触发。我发现,如果我添加一个 /店/
的查询字符串之前,它被内部重定向,没有404被触发。
Any request for /
that has a query string is causing a 404 to be triggered. I've found that if I add a /shop/
before the query string, it gets redirected internally and no 404 is triggered.
我需要一个通用的mod_rewrite规则,将采取一个URL的形式:
I need a general mod_rewrite rule that will take a URL in the form of:
http://www.example.com/?foo=bar
和重定向到:
http://www.example.com/shop/?foo=bar
在查询字符串(可以是任何东西)是preserved。
where the query string (could be anything) is preserved.
这将重定向(URL会改变)所有点击进入ROOT(如 HTTP:// WWW。 example.com /
)的有的查询字符串转换成 http://www.example.com/shop/
。
This will redirect (URL will change) all hits into ROOT (e.g. http://www.example.com/
) that has query string into http://www.example.com/shop/
.
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} !^$
RewriteRule ^$ http://www.example.com/shop/ [QSA,R,L]
这将重写内部(URL会留在浏览器中一样)的所有点击进入ROOT(如 http://www.example.com/
)的有的查询字符串转换成 http://www.example.com/shop/
。
This will rewrite internally (URL will stay the same in browser) all hits into ROOT (e.g. http://www.example.com/
) that has query string into http://www.example.com/shop/
.
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} !^$
RewriteRule ^$ /shop/ [QSA,L]