簡體   English   中英

基於語言變量的.htaccess中的RewriteRule

[英]RewriteRule in .htaccess based on language variable

我有一個網站,其中包含德語作為默認語言和英語作為替代語言。 我想根據語言條件將rss URL重定向到網站中的其他路徑。

我的意思是http://www.eample.com/rss.xmlhttp://www.eample.com/index.php?type=11在默認情況下並http://www.eample.com/en/rss如果使用其他語言,則將.xml轉換http://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]

你們能幫我實現這個目標嗎?

嘗試這個 :

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]

也許拋出一些正則表達式以捕獲其他國家/地區代碼。

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]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM