gpt4 book ai didi

apache - 如何强制 http ://in htaccess?

转载 作者:行者123 更新时间:2023-12-04 08:52:29 27 4
gpt4 key购买 nike

我目前在我的 htaccess 文件中有这个,可以在我登录和注册页面的所有页面上强制使用 https:

# Force https://
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{HTTPS} off
RewriteCond $1 ^(sign-in|sign-up) [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

我想在页面未登录或注册时强制使用 http。我怎么做?

编辑 1:

我实际上需要执行以下操作:
  • https://用于 sign-up 中的页面和 sign-in
  • http://对于不在 sign-up 中的页面和 sign-in
  • 删除 www
  • 删除 index.php

  • 我的 .htaccess 的相关部分是这样的:
    #
    # Force https:// or http://
    #
    <IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{HTTPS} off
    RewriteCond $1 ^(sign-in|sign-up) [NC]
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    #RewriteCond %{HTTPS} on
    #RewriteCond $1 !^(sign-in|sign-up) [NC]
    #RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    #RewriteCond %{HTTPS} on
    #RewriteCond %{REQUEST_URI} !^/(sign-in|sign-up)(/|$) [NC]
    #RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    </IfModule>

    #
    # Supress "www" at the beginning of URLs. Source: HTML5 Boilerplate
    #
    <IfModule mod_rewrite.c>
    RewriteEngine On

    #RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
    </IfModule>

    #
    # Supress "index.php"
    #
    <IfModule mod_rewrite.c>
    RewriteEngine On

    # Removes index.php from ExpressionEngine URLs
    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]
    </IfModule>

    最佳答案

    有这样的规则:

    RewriteEngine On

    # force HTTPS for sign-in|sign-up
    RewriteCond %{HTTPS} off
    RewriteRule ^(sign-in|sign-up)(/|$) https://%{HTTP_HOST}%{REQUEST_URI} [NC,L,R=301]

    # force HTTP for NOT sign-in|sign-up
    RewriteCond %{HTTPS} on
    RewriteCond %{REQUEST_URI} !^/(sign-in|sign-up)(/|$) [NC]
    RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    关于apache - 如何强制 http ://in htaccess?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20558002/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com