1

嗨,我在 bluehost 上托管了这个子域。我在整个互联网上进行了搜索,但我想.. 没有人像我一样遇到问题 :(

我所做的是在 .htaccess 中添加了这行代码

#RewriteCond %{SERVER_PORT} 80
#RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]

那就是将所有网址重定向到https。

但是当我访问该网站时,我得到了

https://ci.domain.com/~hevronwo/ci/~hevronwo/ci/~hevronwo/ci/~hevronwo/ci/~hevronwo/ci/~hevronwo/ci/~hevronwo/ci/~hevronwo/ci/~hevronwo/ci/~hevronwo/ci/~hevronwo/ci/~hevronwo/ci/~hevronwo/ci/~hevronwo/ci/~hevronwo/ci/~hevronwo/ci/~hevronwo/ci/~hevronwo/ci/~hevronwo/ci/user/default/dashboard/start/19

仅供参考:phpinfo() 让我启用了 openssl。我的 .htaccess 代码:

# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
IndexIgnore */*

RewriteEngine on

RewriteBase /

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#RewriteCond %{SERVER_PORT} 80
#RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]

RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,QSA,NE]

# otherwise forward it to index.php
RewriteRule . index.php

#RewriteCond $1 !^(index\.php|robots\.txt)
#RewriteRule ^(.*)$ index.php/$1 [L]
4

2 回答 2

2

尝试使用此代码强制使用 HTTPS:

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,QSA,NE]

您完整的 .htaccess:

# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
IndexIgnore */*

RewriteEngine on
RewriteBase /

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,QSA,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
于 2013-11-10T07:50:57.977 回答
0

这将强制 http 到 https
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

于 2021-11-06T04:05:05.040 回答