【问题标题】:redirect www to non www in wordpress [duplicate]在wordpress中将www重定向到非www [重复]
【发布时间】:2020-09-05 01:03:30
【问题描述】:

我已将非 www url 添加到我的常规 - 设置 - WordPress 地址 (URL) 和站点地址 (URL)

并编辑了我的 wordpress .htaccess 如下。但它仍然没有重定向到非 www 站点,知道为什么吗?

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /

# remove www
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

【问题讨论】:

    标签: wordpress apache .htaccess ovh


    【解决方案1】:

    您可以使用以下重写规则,即

    RewriteCond %{HTTP_HOST} ^www\.example\.com$
    RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
    

    如果您不想使用 Mod 重写规则,请使用重定向,即

    <VirtualHost 127.0.0.1:80>
            ServerName www.example.com
            Redirect permanent / http://example.com/
    </VirtualHost>
    

    【讨论】:

      猜你喜欢
      • 2018-07-18
      • 2018-05-26
      • 2015-08-03
      • 2018-06-06
      • 1970-01-01
      • 2018-11-12
      • 2014-11-26
      • 2019-03-09
      相关资源
      最近更新 更多