基于语言变量的 .htaccess 中的 RewriteRule
RewriteRule in .htaccess based on language variable
我有一个网站,默认语言为德语,备选语言为英语。我想根据语言条件将我的 rss url 重定向到网站中的另一个路径。
我是说
http://www.eample.com/rss.xml to http://www.eample.com/index.php?type=11 在默认情况下和
http://www.eample.com/en/rss.xml to 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]
也许加入一些正则表达式来捕获额外的 country/language 代码。
RewriteRule ^rss\.xml$ /index.php?type=11 [NC,L,R=301]
RewriteRule ^(en|de|fr)/rss\.xml$ /index.php?type=11&L= [NC,L,R=301]
或匹配任意两个字符
RewriteRule ^([a-z]{2})/rss\.xml$ /index.php?type=11&L= [NC,L,R=301]
我有一个网站,默认语言为德语,备选语言为英语。我想根据语言条件将我的 rss url 重定向到网站中的另一个路径。
我是说 http://www.eample.com/rss.xml to http://www.eample.com/index.php?type=11 在默认情况下和 http://www.eample.com/en/rss.xml to 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]
也许加入一些正则表达式来捕获额外的 country/language 代码。
RewriteRule ^rss\.xml$ /index.php?type=11 [NC,L,R=301]
RewriteRule ^(en|de|fr)/rss\.xml$ /index.php?type=11&L= [NC,L,R=301]
或匹配任意两个字符
RewriteRule ^([a-z]{2})/rss\.xml$ /index.php?type=11&L= [NC,L,R=301]