2011-03-04 81 views
1

我想将所有请求重定向到站点上的子文件夹。所以:使用GET变量重定向Apache

http://thesite.com/oldfolder/whatever/anything.php?getvar_stuff 

http://thesite.com/newfolder/ 

如果我用下面的.htaccess文件:

RedirectMatch 301 /oldfolder http://thesite.com/newfolder/ 

..返回网址是:

http://thesite.com/newfolder/?getvar_stuff 

唐不想要“post_stuff”,所以我将重写行更改为:

RedirectMatch 301 /oldfolder http://thesite.com/newfolder/? 

..返回网址是:

http://thesite.com/newfolder/? 

哪个更好,但我仍然希望失去的问号。可能吗?

回答

0

看来,要做到这一点最好的办法是不使用重定向,而是重写:

RewriteEngine On 
RewriteCond %{REQUEST_URI} ^/oldfolder/ 
RewriteRule ^(.*)$ http://thesite.com/newfolder/? [R=301,L]