2012-12-04 4 views
0

저는 이미 한 시간 동안이 작업을 해왔으므로 물어볼 수도 있습니다.CodeIgniter .htaccess를 사용하여 index.php를 제거하십시오.

CodeIgniter 앱의 URL에서 index.php를 제거하려고 시도하고 있습니다. 이 내 기본 가상 호스트 블록 여기

<VirtualHost 192.168.1.90:80> 
    ServerAdmin [email protected] 
    DocumentRoot "/var/www/smr.dev/app" 
    ServerName smr_local 
    ErrorLog "/etc/httpd/logs/error_log" 
    CustomLog "/etc/httpd/logs/access_log" common 
    <Directory /var/www/smr.dev/app> 
     Order allow,deny 
     Allow from all 
     AllowOverride All 
    </Directory> 
    <IfModule mod_rewrite.c> 
     RewriteEngine on 
    </IfModule> 
</VirtualHost> 

입니다

응용 내 사무실에서 전용 서버에서 실행되고 나는 URL을 http://smr_local

을 통해 응용 프로그램에 액세스하는 것은 내 htaccess로 파일

입니다
RewriteEngine on 
RewriteBase/
# Hide the application and system directories by redirecting the request to index.php 
RewriteRule ^(application|system|\.svn) index.php/$1 [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php/$1 [QSA,L] 

그리고 내 config 파일

$config['base_url'] = "http://smr_local/"; 
$config['index_page'] = ''; 
$config['uri_protocol'] = 'REQUEST_URI'; 

지금 내베이스 URL에 액세스하려고 할 때 http://smr_local/user/courses 내 아파치 오류 로그에 오류가 발생합니다.

File does not exist: /var/www/smr.dev/app/user 

정말 다음에 무엇을 시도해야할지 모르겠다. 어떤 도움을 주시면 감사하겠습니다.

답변

1

공식 user guide을 확인하셨습니까?

example.com/index.php/news/article/my_article 

간단한 규칙으로 .htaccess 파일을 사용하면이 파일을 쉽게 제거 할 수 있습니다. 다음은 이러한 파일의 일례는 모든 지정된 상품 제외 리디렉션되는 "네거티브"메소드를 사용한다 : 위의 예에서

RewriteEngine on 
RewriteCond $1 !^(index\.php|images|robots\.txt) 
RewriteRule ^(.*)$ /index.php/$1 [L] 

를 index.php에, 이미지 이외의 HTTP 요청 robots.txt는 index.php 파일에 대한 요청으로 처리됩니다.


내가 이전에 CodeIgniter를 함께 일하고있다 그리고 내가 그것을 작동시킬 방법입니다

여기

가 내 .htaccess (당신이 기본 폴더 구조를 가정) :

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/

    # Removes access to the system folder by users. 
    RewriteCond %{REQUEST_URI} ^system.* 
    RewriteRule ^(.*)$ /index.php?/$1 [L] 

    # Prevents user access to the application folder 
    RewriteCond %{REQUEST_URI} ^application.* 
    RewriteRule ^(.*)$ /index.php?/$1 [L] 

    # Checks to see if the user is attempting to access a valid file, 
    # such as an image or css document, if this isn't true it sends the 
    # request to index.php 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule> 

<IfModule !mod_rewrite.c> 
    ErrorDocument 404 /index.php 
</IfModule> 

즉 관련 부분 config.php :

$config['base_url'] = ''; 
$config['index_page'] = ''; 
$config['uri_protocol'] = 'AUTO'; 
$config['url_suffix'] = ''; 

이 방법이 도움이되지 않는다면 Apache 구성에서 문제가 발생할 가능성이 있습니다.

그런 다음 httpd.conf 및 기타 관련 구성 (virtual-hosts)을 제공하십시오.

+0

예, 제가 시도한 첫 번째 작업이었습니다. 작동하지 않습니다. – nicks451

+0

@ nicks451 답변을 업데이트했습니다.보세요. –

관련 문제