2012-07-14 2 views
0

나는 그물을 검색하여 결과를 얻지 못한 채로 지난 몇 시간 동안 대부분의 것을 지금 시도했습니다.codeigniter에서 SSL을 강제 실행합니다.

저는 CodeIgniter에서 사용하고 있습니다. Htaccess 파일에는 몇 가지 규칙이 있습니다.

SSL 연결을 강제 실행하고 url에서 index.php를 제거하고 싶습니다.

여기에 문제는 그것이 작동하지 않는다는 것입니다 내 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에 인증서가 설치되어 있고 모든 트래픽이 있어야합니다.

http://www.lotusmodellen.se 또는 당신이 또는 https없이, 쓰기 무엇이든

http://lotusmodellen.se에 들어가보십시오 lotusmodellen.se하지 않기 위하여, 당신은

을 www.lotusmodellen.se 와서해야하지만 문제가 될 것으로 보인다 , 리디렉션 오류 또는 뭔가. 그것은 작동하지 않기 때문입니다.

해결책이있는 사람이 있습니까?

답변

0

안녕하세요. config.php 파일에서 base_url을 바꾸면 https의 요청을 확인하거나 http가 base_url을 설정합니다.

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/'; 
} 
관련 문제