2016-08-15 3 views
0

codeigniter 프레임 워크를 사용하고 있습니다. .htaccess 파일을 설정하여 index.php를 제거하고 서버에 HTTPS 프로토콜을 사용하도록 설정하려고했습니다.CodeIgniter에서 HTTPS를 제거하고 index.php를 제거하십시오.

HTTP : 나는 액세스 할 때

  1. 다 괜찮 http://www.example.com/controller/method 또는 http://www.example.com/index.php/controller/method

HTTPS :

  1. 모든 것은 내가 액세스 할 때, 괜찮 https://www.example.com/index.php를/컨트롤러/메소드

  2. 내가

나는 그 htaccess로 파일 문제라고 생각 https://www.example.com/controller/method에 액세스 할 때

  • 있어 404를 찾을 수 없습니다, 그것은 htaccess로 파일이 HTTPS 프로토콜 작동하지 않는 모습이다.

    내 사이트의 .htaccess 파일

    DirectoryIndex index.php 
    RewriteEngine on 
    
    RewriteCond %{HTTPS} off 
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
    
    RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|js|robots\.txt|favicon\.ico) 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ ./index.php?$1 [L,QSA] 
    

    문제인가요? 고마워.

  • +0

    파일 이름과 클래스의 첫 글자 만 대문자로 입력했는지 확인했는지 확인하십시오. – user4419336

    +0

    @ wolfgang1983 파일 이름이 정확하고 모든 것이 HTTP 프로토콜을 통해 웹 사이트에 액세스 할 때 작동하지만 HTTPS 프로토콜을 통해 웹 사이트에 액세스 할 때 HTTPS 프로토콜에서만 작동하지 않는 .htaccess 파일처럼 보입니다. –

    답변

    0

    먼저 $의 설정을 제거 [ 'BASE_URL] 설정 파일 넣어에서' '당신의 $의 설정에서 (빈)'지수 '] 속성 ..

    처럼 htaccess로 파일을 설정하십시오 ..

    <IfModule mod_rewrite.c> 
    RewriteEngine On 
    
        RewriteCond %{REQUEST_FILENAME} !-f 
        RewriteCond %{REQUEST_FILENAME} !-d 
    
        # Rewrite all other URLs to index.php/URL 
        RewriteRule ^(.*)$ index.php?url=$1 [PT,L] 
        </IfModule> 
        <IfModule !mod_rewrite.c> 
         ErrorDocument 404 index.php 
        </IfModule> 
    
    +0

    죄송합니다. https 프로토콜에서만 작동하는 http 전용으로 작동합니다. –

    0

    내가 내 프로젝트 중 하나로이를 사용하십시오. 월 자사의 웹 사이트 이름으로 대체해야 위의 htaccess로 당신

    #AuthType Basic 
    #AuthName "restricted area" 
    #AuthUserFile /home/site_name/public_html/.htpasswd 
    #require valid-user 
    
    RewriteEngine On 
    #RewriteBase/
    
    RewriteCond %{SERVER_PORT} 80 
    RewriteRule ^(.*)$ https://www.site_name.com/$1 [R,L] 
    
    RewriteCond %{HTTP_HOST} ^([a-z.]+)?.site_name.lk$ [NC] 
    RewriteRule ^(.*)$ https://www.site_name.com/$1 [R=301,L] 
    
    RewriteCond %{HTTP_HOST} ^([a-z.]+)?site_name\.com$ [NC] 
    RewriteCond %{HTTP_HOST} !^www\. [NC] 
    RewriteRule .? https://www.%1site_name.com%{REQUEST_URI} [R=301,L] 
    
    <IfModule mod_rewrite.c> 
        RewriteEngine on 
        RewriteCond %{REQUEST_FILENAME} !-f 
        RewriteCond %{REQUEST_FILENAME} !-d 
    # RewriteCond $1 !^(index\.php|assets|files|robots\.txt) 
    # RewriteRule ^(.*)$ /index.php/$1 [L] 
    
        RewriteRule ^(.*)$ index.php/$1 [L,QSA] 
    </IfModule> 
    

    에게 주site_name하는 데 도움이

    +0

    아직도 작동하지 않음 = ( –

    0
    당신이 시도 할 수

    , 그것은 내 프로젝트에 대한 작동 .

    RewriteEngine On 
    RewriteCond %{HTTPS} !=on 
    RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] 
    
    RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|js|robots\.txt|favicon\.ico) 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php/$1 [L,QSA] 
    

    참조 : https://wiki.apache.org/httpd/RewriteHTTPToHTTPS

    0

    참고 : SSL 재 작성이 .htaccess 파일의 index.php 재 작성하기 전에 발생한다.

    따라서이 설정을 사용하지 마십시오. 서버 apache 구성 파일에서는 아무 것도 변경하지 않으므로이 설정을 사용하지 마십시오. )

    는에 AllowOverride 모든

    그냥 2 작동 설정이 적용됩니다.


    저도 같은 문제에 직면하고

    에 AllowOverride 1 설정 모든

    추가하여 해결 한 : 참고로 우리가이 개 설정 파일을 을. (http로 실행)

    1. 기본 아파치 설정 (https로 실행)
    2. SSL의 설정

    이동 SSL의 설정과

    <Directory "/var/www/html"> 
        AllowOverride All 
    </Directory> 
    

    ** 2 설정 추가 : ** .htaccess 파일은 다음과 같아야합니다.

    RewriteEngine On 
    RewriteCond %{HTTPS} !=on  
    RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
    
    <IfModule mod_rewrite.c> 
        RewriteEngine on 
        RewriteCond %{REQUEST_FILENAME} !-f 
        RewriteCond %{REQUEST_FILENAME} !-d 
        RewriteRule^index.php [L] 
    </IfModule> 
    

    그것은 나를 위해 일했습니다.

    관련 문제