.htaccess - 如何使 ssl 在 bluehost 中工作?

标签 .htaccess ssl bluehost

您好,我在 bluehost 上托管了这个子域。 我在整个互联网上都进行了搜索,但我想..没有人遇到过我遇到的问题:(

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

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

将所有 url 重定向到 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]

最佳答案

尝试使用此代码强制使用 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

关于.htaccess - 如何使 ssl 在 bluehost 中工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19887398/

相关文章:

PHP 获取 URL 作为变量

MySQL + htaccess mod_rewrite?

php - RewriteRule 不适用于生产服务器

apache - 在本地主机上使用 SSL 的 Yii2 高级应用程序

ssl - Safari 不断重新加载带有自定义 CA 证书的页面

amazon-web-services - 在 AWS 路由 53 上配置通配符记录

ruby-on-rails - BlueHost - 没有这样的文件或目录服务器是否在本地运行并接受 Unix 域套接字 "/tmp/.s.PGSQL.5432"上的连接

.htaccess - 使用 Codeigniter 临时关闭站点(301 可能使用 routes.php?)

python - Flask-socketio 服务器和 python-socketio 之间的安全通信

WordPress 我更改了数据库用户密码,但网站无法连接数据库