【问题标题】:convert https non www domain to https www [duplicate]将https非www域转换为https www [重复]
【发布时间】:2016-08-11 11:36:56
【问题描述】:

我想自动从example.com 重定向到www.example.com

这是我的 wordpress htaccess 代码.....

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com//$1 [R,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

【问题讨论】:

    标签: wordpress .htaccess


    【解决方案1】:

    这可能对你有帮助:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
    RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301]
    

    它会自动在您的域中添加 www。

    例如:https://fastassignmenthelp.co.uk/https://www.fastassignmenthelp.co.uk/

    【讨论】:

      【解决方案2】:

      转换

      您可以使用以下规则:

      RewriteEngine on
      RewriteCond %{HTTPS} on
      RewriteCond %{HTTP_HOST} !^www\.
      RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R]
      

      当您确定规则工作正常时,只需将 R 更改为 R=301

      【讨论】:

        【解决方案3】:
        RewriteEngine On
        RewriteCond %{HTTPS_HOST} ^yourdomain.com [NC]
        RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [L,R=301]
        

        从现在开始,当有人访问https://yourdomain.com时,他/她将被重定向到https://www.yourdomain.com

        【讨论】:

          猜你喜欢
          • 2023-03-16
          • 2014-12-16
          • 2017-12-04
          • 2015-04-06
          • 1970-01-01
          • 1970-01-01
          • 2018-12-30
          • 2018-04-22
          • 1970-01-01
          相关资源
          最近更新 更多