2011-03-04 80 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]