【问题标题】:Divert http non-www to http www, & https non-www to https www将 http 非 www 转为 http www,将 https 非 www 转为 https www
【发布时间】:2023-03-16 16:23:02
【问题描述】:

下面的 htaccess 命令将所有非 www 转移到 http www

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

如何通过各自的 http/https 将非 www 转移到 www?

【问题讨论】:

  • 那么,这和 PHP 有什么关系?
  • 对不起。我是新手。

标签: linux apache .htaccess server


【解决方案1】:

我使用了以下代码:

重写引擎开启

RewriteCond %{HTTP_HOST} !^www.

RewriteCond %{HTTPS} 关闭 [OR]

RewriteCond %{HTTPS}:s on:(s)

重写规则 ^(.*)$ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

【讨论】:

    猜你喜欢
    • 2017-12-04
    • 2014-12-16
    • 2018-12-30
    • 1970-01-01
    • 1970-01-01
    • 2018-09-26
    • 1970-01-01
    • 2015-04-06
    • 2016-08-11
    相关资源
    最近更新 更多