gpt4 book ai didi

php - 如何防止子域名被重定向到https

转载 作者:行者123 更新时间:2023-12-02 21:34:25 25 4
gpt4 key购买 nike

我想将网站重定向到 https://,但我不希望子域被重定向。当我输入:dev.mycreditstatus.co.za 时,它会被重定向到 https://,即使我不希望它这样做。

这是我当前 .htaccess (public_ssl) 中的代码:

ErrorDocument 404 https://mycreditstatus.co.za/404.php

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^imupost\.co\.za$ [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

.htaccess (public_html):

ErrorDocument 404 https://mycreditstatus.co.za/404.php

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/(pp5fdr) [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

我应该进行哪些修改才能使其正常工作?谢谢!

最佳答案

在您的 public_html .htaccess 中,您没有任何条件将其仅限于主域(这假设您的子域 Root 于同一目录)。您需要另一个 RewriteCond 来仅匹配主域:

ErrorDocument 404 https://mycreditstatus.co.za/404.php

RewriteEngine On
RewriteCond %{HTTPS} off
# Only redirect to https if the main domain (no subdomain) is matched
# case-insensitively in HTTP_HOST
RewriteCond %{HTTP_HOST} ^mycreditstatus\.co\.za$ [NC]
RewriteCond %{REQUEST_URI} !^/(php05142013) [NC]
# added flags...
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

关于php - 如何防止子域名被重定向到https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21718057/

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