【问题标题】:How to make ssl working in bluehost?如何使 ssl 在 bluehost 中工作?
【发布时间】:2013-11-22 03:15:38
【问题描述】:

嗨,我有这个子域托管在 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]

【问题讨论】:

    标签: .htaccess ssl bluehost


    【解决方案1】:

    试试这个代码来强制使用 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
    

    【讨论】:

    • 嗨 anubhava.. 非常感谢您的回复.. 但我仍然遇到同样的问题.. 如果您想查看完整的 .htaccess 代码我现在正在更新,请检查上述问题..
    • 您可以尝试添加 RewriteCind 以检查您的第二行的文件/目录吗?
    • 嗨 anubhav thnx.. 但我不会通过它.. 你可以检查你自己.. at ci.flockminer.com
    • 您是否使用过上述建议的 .htaccess,请说明您的预期行为是什么,哪些对您不起作用?
    • 嗨,是的,确实用您提供的代码替换了我的 htaccess 代码,但除了第一个登录页面外,我仍然收到https://ci.domain.com/~hevronwo/ci/~hevronwo/ci/~hevronwo/ci/~hevronwo/ci/~hevron....。登录页面 url 在flockminer.com/~hevronwo/ci 中发生变化
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-31
      • 2010-12-17
      • 2014-10-04
      • 1970-01-01
      • 2021-09-24
      • 1970-01-01
      • 2017-02-05
      • 2013-01-02
      相关资源
      最近更新 更多