力SSL在codeigniterSSL、codeigniter

2023-09-02 01:08:38 作者:EXO,爱到失控

我已经搜查了网,并试图大部分事情了,最后几个小时,但没有结果。

I have searched the net and tried most things now, the last few hours but without result.

我用出了codeIgniter,我有一个。的.htaccess文件,在那里我有一些规则。

I use out of CodeIgniter and I have a. Htaccess file where I have some rules.

我想强制SSL连接,并从URL中删除的index.php。

I want to force SSL connection and remove index.php from url.

下面是我的.htaccess

Here is my .Htaccess

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /

    # Force SSL
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

    #remove ugly index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin
    ErrorDocument 404 /index.php
</IfModule> 
Options All -Indexes

的问题是,它不工作。我已经安装上www.lotusmodellen.se证书,所有车辆必须去那里。不要lotusmodellen.se

The problem is that it does not work. I have the certificate installed on www.lotusmodellen.se and all traffic must go there. Not to lotusmodellen.se

请尽量走成这样 http://www.lotusmodellen.se 或的 http://lotusmodellen.se

无论你写的,有或没有HTTPS,你应该来www.lotusmodellen.se

Whatever you write, with or without https, you should come to www.lotusmodellen.se

不过,这似乎是问题,重定向错误什么的。对于这是行不通的。

But it seems to be problems, redirect error or something. For it does not work.

有没有人有办法解决吗?

Does anyone have a solution?

推荐答案

喜只需更换的config.php文件的BASE_URL这将检查或者请求从https或http将根据该设置BASE_URL。

hi just replace your base_url in config.php file this will check either request from https or http will set your base_url according to that.

if(isset($_SERVER['HTTP_HOST']))
{
    $config['base_url'] = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https' : 'http';
    $config['base_url'] .= '://'. $_SERVER['HTTP_HOST'];
    $config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
}

else
{
    $config['base_url'] = 'http://localhost/';
}