gpt4 book ai didi

.htaccess 文件没有将 HTTP 重定向到 HTTPS

转载 作者:太空宇宙 更新时间:2023-11-03 14:28:54 24 4
gpt4 key购买 nike

我刚刚从 GoDaddy 购买了 UCC/SAN SSL 证书,现在我正在尝试让我的网站 (mannyrothman.com) 自动从 HTTP 重定向到 HTTPS。

这是我的“.htaccess”文件的内容:

## Go Daddy servers need the Options -MultiViews code below
Options -MultiViews
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Hide .html extension
## External Redirect
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\index.html [NC]
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ %1 [R,NC]

## ## Internal Redirect
RewriteCond %{REQUEST_FILENAME}index.html -f
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ %{REQUEST_URI}index.html
# Begin Muse Generated redirects
# End Muse Generated redirects

最佳答案

您可以使用此代码

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R,L]

如果你想从 https://ww.stackoverflow.com/ 重定向至 https://stackoverflow.com/也用这个

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.rawertest.com [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]

关于.htaccess 文件没有将 HTTP 重定向到 HTTPS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54471821/

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