2016-05-12 47 views
0

我在我的網站上有幾種語言。從.htaccess的URL獲取語言

在根目錄我有一個index.php。這是我的主頁。

我想這種類型的網址:domain.com/fr/或​​

女巫必須是相同的domain.com/index.php?lang=frdomain.com/index.php?lang=en

所以我用這個的.htaccess規則:

# Redirect to a page (xxxxx.com/index.php?lang=fr) 
RewriteRule ^(fr|en|es|cn|ar)/index$ index.php?lang=$1 [L] 

但它不工作。

你能幫我解決嗎?

感謝。

回答

0

您可以使用:

RewriteEngine On 
RewriteRule ^(fr|en|es|cn|ar)/$ index.php?lang=$1 [L] 
+0

如果我想有一個默認的語言? – PacPac

+0

看看http://stackoverflow.com/questions/8133094/rewriterule-for-htaccess-to-hide-default-language或這裏http://stackoverflow.com/questions/16854820/htaccess-rule-for-語言檢測 –