如何让ssl在bluehost中工作?

时间:2013-11-10 07:43:27

标签: .htaccess ssl bluehost

您好我在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]

1 个答案:

答案 0 :(得分: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