2014-02-05 55 views
1

我已經改變了我的網站的結構:刪除/ nl /文件夾,並將下劃線切換到條紋。 所以希望是重定向舊的網頁: www.domain.com/nl/citygames_leuven 到 http://www.domain.com/citygames-leuven如何重寫乾淨的網址結構與httaccess

重定向了一下作品;但遇到問題,我乾淨的URL重定向。 我被重定向到: http://www.domain.com/citygames-leuven?url=nl/citygames_leuven

正如你所見; url參數會粘在頁面上並給出錯誤。

這是我的代碼至今:

Options All -Indexes 
RewriteEngine On 
RewriteBase/


RewriteRule ^teambuilding/(.*)/?$ teambuilding.php?url=$1 [L] 
RewriteRule ^citygame/(.*)/?$ citygame.php?url=$1 [L] 
RewriteRule ^meeting/(.*)/?$ meeting.php?url=$1 [L] 
RewriteRule ^aanzee/(.*)/?$ aanzee.php?url=$1 [L] 
RewriteRule ^vip/(.*)/?$ vip.php?url=$1 [L] 
RewriteRule ^verhuur/(.*)/?$ verhuur.php?url=$1 [L] 
RewriteRule ^nieuws/(.*)/?$ nieuws.php?url=$1 [L] 


#Url omzetten naar index.php?page= 
RewriteCond %{REQUEST_FILENAME} !-f [NC] 
RewriteCond %{REQUEST_FILENAME} !-d [NC] 
RewriteRule ^(.+)$ page.php?url=$1 [QSA] 



Redirect 301 /nl/citygames_antwerpen http://www.domain.com/citygames-antwerpen 
Redirect 301 /nl/citygames_leuven http://www.domain.com/citygames-leuven 
Redirect 301 /nl/teambuilding/offroad_buggy http://www.domain.com/teambuilding/offroad-buggy 

感謝您的幫助!

回答

1

重新排序規則和之前內部重寫規則放置301:

Options All -Indexes 
RewriteEngine On 
RewriteBase/

RewriteRule ^nl/citygames_antwerpen/?$ /citygames-antwerpen [L,R=301] 
RewriteRule ^nl/citygames_leuven/?$ /citygames-leuven [L,R=301] 
RewriteRule ^nl/teambuilding/offroad_buggy/?$ /teambuilding/offroad-buggy [L,R=301] 

RewriteRule ^teambuilding/(.*)/?$ teambuilding.php?url=$1 [L] 
RewriteRule ^citygame/(.*)/?$ citygame.php?url=$1 [L] 
RewriteRule ^meeting/(.*)/?$ meeting.php?url=$1 [L] 
RewriteRule ^aanzee/(.*)/?$ aanzee.php?url=$1 [L] 
RewriteRule ^vip/(.*)/?$ vip.php?url=$1 [L] 
RewriteRule ^verhuur/(.*)/?$ verhuur.php?url=$1 [L] 
RewriteRule ^nieuws/(.*)/?$ nieuws.php?url=$1 [L] 

#Url omzetten naar index.php?page= 
RewriteCond %{REQUEST_FILENAME} !-f [NC] 
RewriteCond %{REQUEST_FILENAME} !-d [NC] 
RewriteRule ^(.+)$ page.php?url=$1 [L,QSA] 

PS:也更好地做到這mod_rewrite本身並避免mod_alias規則。

+0

非常感謝!現在它工作正常。非常感謝。 – DaveL

+0

偉大你現在可以將答案標記爲已接受。 – anubhava