【问题标题】:.htaccess to force HTTPS on all the site, and to force HTTP on one specific folder.htaccess 在所有站点上强制使用 HTTPS,并在一个特定文件夹上强制使用 HTTP
【发布时间】:2018-08-05 13:18:47
【问题描述】:

我有一个网站,WordPress 安装在根文件夹中。我需要为 WordPress 强制使用 HTTPS。同时,我有一个文件夹,其中安装了另一个 cms,我想强制 HTTP。

我怎样才能做到这一点?

补充说明:

  • example.com 打开 WordPress 我要强制 HTTPS
  • example.com/xyz打开另一个软件我要强制HTTP

【问题讨论】:

    标签: wordpress .htaccess https


    【解决方案1】:

    您可以通过将以下详细信息添加到您的 .httaccess 文件来创建子目录站点

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

    如果您想强制使用 HTTPS,请添加以下行

         # BEGIN WordPress
        <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /xyz/
        RewriteRule ^index\.php$ - [L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /xyzy/index.php [L]
       # Rewrite HTTP to HTTPS
       RewriteCond %{HTTPS} !=on
       RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]
        </IfModule>
    
        # END WordPress
    

    确保您已更改目录路径服务器名称。如果您想在没有 https 的情况下加载站点,请删除 https 并添加您的服务器路径。

    【讨论】:

    • 我想你误解了我的问题。实际上 WordPress 有指向其他软件的链接。因此,当我在 WordPress 站点中强制使用 https 并使用同一站点中的链接转到子文件夹中的应用程序时,它也会加载为 https。第二个软件中的某些设计元素无法在 https 上加载。因此,我希望对这个特定文件夹强制使用 http,而对原始根站点强制使用 https
    猜你喜欢
    • 2018-05-08
    • 2013-01-22
    • 2018-03-29
    • 2015-01-08
    • 2015-11-28
    • 1970-01-01
    • 2011-06-11
    • 2016-04-27
    • 1970-01-01
    相关资源
    最近更新 更多