【问题标题】:remove default language from .htaccess seo url从 .htaccess seo url 中删除默认语言
【发布时间】:2015-10-24 12:06:29
【问题描述】:

我像这样使用.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 url 中删除 en

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

我的意思是从 seo url 中删除 en,仅用于默认语言 en。我怎样才能生成这个?!

【问题讨论】:

    标签: php apache .htaccess slug


    【解决方案1】:
    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]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-18
      • 2015-09-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多