2015-05-28 15 views
1

我有一個包含德語作爲默認語言和英語作爲替代語言的網站。我想根據語言條件將我的rss url重定向到網站中的另一個路徑。基於語言變量的.htaccess中的RewriteRule

我的意思是 http://www.eample.com/rss.xml在默認情況下http://www.eample.com/index.php?type=11http://www.eample.com/en/rss.xmlhttp://www.eample.com/index.php?type=11&L=1在替代語言的情況下。

我以下面的方式嘗試了這一點,但它只尊重默認情況。

RewriteRule rss.xml$ /index.php?type=11 [L,R=301] 
RewriteRule en/rss.xml$ /index.php?type=11&L=1 [L,R=301] 

你們能幫我實現嗎?

回答

1

試試這個:

RewriteRule ^rss\.xml$ /index.php?type=11 [NC,L,R=301] 
RewriteRule ^en/rss\.xml$ /index.php?type=11&L=1 [NC,L,R=301] 
+1

非常感謝你much..Works就像一個魅力.. :) –

1

也許扔在一些正則表達式來獲取額外的國家/語言代碼。

RewriteRule ^rss\.xml$ /index.php?type=11 [NC,L,R=301] 
RewriteRule ^(en|de|fr)/rss\.xml$ /index.php?type=11&L=$1 [NC,L,R=301] 

或匹配任何兩個字符

RewriteRule ^([a-z]{2})/rss\.xml$ /index.php?type=11&L=$1 [NC,L,R=301]