【问题标题】:Redirect one page only仅重定向一页
【发布时间】:2020-01-24 00:20:05
【问题描述】:

我的网站类似于 example.com/fr/{slug}。

我的 htaccess 中有 RedirectPermanent 来使用 slug 管理页面。

但我的主页是 example.com/fr/,我想将其重定向到 example.com 但只有这个主页。

我试过这个:

RedirectMatch   301 "com\Wfr\W$" "com"

但它不起作用。

我试过这个:

RedirectMatch   301 "\Wfr\W$" "/"

它可以工作,但它是一个多语言网站,例如,当我在西班牙语方面,url 就像这个 example2.es/es/ 和去法语版本的链接就像这个 exmaple2.es/ fr/,由于这个重定向规则,我仍然使用西班牙语版本。

有什么想法可以进行良好的重定向并使 url 更改版本也可以工作吗?

【问题讨论】:

    标签: .htaccess redirect


    【解决方案1】:

    我终于找到了解决办法:

    RewriteCond %{HTTP_HOST} occasion.com$
    RewriteCond %{REQUEST_URI} fr/$
    RewriteRule ^(.*)$ / [R=301,L]
    
    RewriteCond %{HTTP_HOST} barrel.com$
    RewriteCond %{REQUEST_URI} en/$
    RewriteRule ^(.*)$ / [R=301,L]
    
    RewriteCond %{HTTP_HOST} es$
    RewriteCond %{REQUEST_URI} es/$
    RewriteRule ^(.*)$ / [R=301,L]
    
    RewriteCond %{HTTP_HOST} it$
    RewriteCond %{REQUEST_URI} it/$
    RewriteRule ^(.*)$ / [R=301,L]
    
    RewriteRule ^(.*)$ $1
    

    希望有帮助!!

    【讨论】:

      猜你喜欢
      • 2017-09-09
      • 2015-11-24
      • 2013-03-11
      • 2013-03-14
      • 1970-01-01
      • 1970-01-01
      • 2021-04-19
      • 1970-01-01
      • 2016-09-25
      相关资源
      最近更新 更多