【问题标题】:.htaccess https only for homepage and http for other.htaccess https 仅用于主页,http 用于其他
【发布时间】:2016-11-12 00:16:39
【问题描述】:

我有一个安装了 Lets Encrypt SSL 的网站,例如:example.com。我想强制将所有 url 从 https 重定向到 http,但同时我希望主页强制从 http 重定向到 https。这样的事情可能吗? 谢谢。

我当前的 .htaccess

<IfModule mod_rewrite.c>
    RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
    RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
    RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
    RewriteRule .* index.php [F,L]
</IfModule>
Options +FollowSymlinks

RewriteEngine on
RewriteBase /

RewriteCond %{SERVER_PORT} ^443$ [OR]

RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ http://clix2reach.com/$1 [R=301,L]

【问题讨论】:

    标签: .htaccess redirect url-redirection http-redirect


    【解决方案1】:

    你可以试试这个:

    RewriteEngine On
    RewriteBase /
    
    # Turn HTTPs on for homepage
    RewriteCond %{HTTPS} off
    RewriteCond %{REQUEST_URI} ^/index.php
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
    
    # Turn HTTP on for everything but homepage
    RewriteCond %{HTTPS} on
    RewriteCond %{REQUEST_URI} !^/index.php
    RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
    

    根据文件名/扩展名更改index.php

    【讨论】:

      猜你喜欢
      • 2012-10-20
      • 1970-01-01
      • 2013-11-30
      • 1970-01-01
      • 2014-06-11
      • 2014-05-07
      • 1970-01-01
      • 2016-04-03
      • 1970-01-01
      相关资源
      最近更新 更多