从.htaccess中移除默认语言seo url

时间:2015-08-02 07:06:04

标签: php apache .htaccess slug

我使用.htaccess重写多语言网址,如下所示:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(fr/en)/(article|page|gallery)/([0-9]+)/([A-Za-z0-9-]+)/?.html$ index.php?page=$2&id=$3&title=$4&lang=$1 [NC,L,QSA]

输出是:

http://localhost/subdomain/fr/article/1/title1.html
http://localhost/subdomain/en/article/2/title2.html

这适用于两种语言(fr/en)。我的默认语言是en,我需要从slug网址中删除en,如下所示:

 http://localhost/subdomain/article/2/title2.html

我的意思是从seo url中移除en,仅限语言为默认en。我怎么能生成这个?!

1 个答案:

答案 0 :(得分:0)

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

#Rule for "en"
RewriteRule ^(article|page|gallery)/([0-9]+)/([A-Za-z0-9-]+)/?.html$ index.php?page=$1&id=$2&title=$3&lang=en [NC,L,QSA]
#____________

#Rule for "fr"
RewriteRule ^(fr)/(article|page|gallery)/([0-9]+)/([A-Za-z0-9-]+)/?.html$ index.php?page=$2&id=$3&title=$4&lang=$1 [NC,L,QSA]