2013-05-15 2 views
12

나는이 질문을 이미 물어 보았다. 그러나 나는 모든 것을 시도했지만 여전히 URL에서 index.php를 제거 할 수 없었다. 여기UBUNTU에서 codeigniter에서 index.php를 제거하는 방법

Ubuntu 12.10 
PHP : 5.4.6 
Mod_rewrite in on 
CI verson: 2.1 

모양 .htacess 내 세부처럼 ..

RewriteEngine On 
RewriteBase /projectname 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 
나는 또한 아래 링크를하지만 행운 볼

Cannot remove index.php from url CI based site

How to remove "index.php" in codeigniter's path

내 "/ etc/apache2/sites-available/default "는 다음과 같습니다 :

<VirtualHost *:80> 
    ServerAdmin [email protected] 

    DocumentRoot /var/www 
    <Directory /> 
     Options FollowSymLinks 
     AllowOverride None 
     </Directory> 
    <Directory /var/www/> 
     Options Indexes FollowSymLinks MultiViews 
     AllowOverride All 
     Order allow,deny 
     allow from all 
    </Directory> 

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 
    <Directory "/usr/lib/cgi-bin"> 
     AllowOverride None 
     Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 
     Order allow,deny 
     Allow from all 
    </Directory> 

    ErrorLog ${APACHE_LOG_DIR}/error.log 

    # Possible values include: debug, info, notice, warn, error, crit, 
    # alert, emerg. 
    LogLevel warn 

    CustomLog ${APACHE_LOG_DIR}/access.log combined 
</VirtualHost> 

감사합니다. application/config/config.php 변화에

+0

아무것도 너의 로그? –

+0

그리고'$ config [ 'uri_protocol']'설정은 무엇입니까? –

+0

그리고 마지막으로 어떤 오류가 발생합니까? 나는 "개체를 찾을 수 없다"고 의심합니까? –

답변

5

:

$config['index_page'] = 'index.php'; 

에 :

$config['index_page'] = ''; 

당신이 아파치 설정 파일을 변경 아파치 재 장전 매번를 수행하는 것이 좋습니다.

sudo /etc/init.d/apache2 reload 

나 :

sudo service apache2 reload 

나 :

sudo /etc/init.d/httpd reload 

(또는 어떤 플랫폼에 해당하는 명령입니다) 여기 내입니다 그것은 가치가 무엇인지에 대한

가. htaccess

RewriteEngine on 
RewriteBase/
RewriteCond $1 !^(index\.php|static|robots\.txt|favicon\.ico|uploads|googlexxxxxxxx\.html|mobile.html) 
RewriteRule ^(.*)$ index.php/$1 [L] 
+0

예 그 중 하나도 업데이트했습니다. –

+0

예, 시간이 내 아파치 번호를 다시 시작했습니다. 사용하지 마십시오. –

+0

htaccess 파일을 사용해 보았는데 성공하지 못했습니다. 내 CI가이 폴더 아래에 있으므로 "RewriteBase/projectname"을 변경합니다. –

0

내 htaccess로

RewriteEngine on 

RewriteCond $1 !^(index.php) 

RewriteRule ^(.*)$ index.php/$1 [L] 
+0

이 시도가 성공하지 못했습니다. –

+0

httpd.conf, AllowOverride 변경 없음 -> AllowOverride 모두 – blu

+0

Asker 코드에서''를보십시오. –

46

1 단계 :

제거 지수 :

은 htaccess로 파일

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    #RewriteBase/

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule^index.php [QSA,L] 
</IfModule> 

2 단계에서 이것을 추가합니다.CodeIgniter의의 설정에서 PHP

$config['base_url'] = ''; 
$config['index_page'] = ''; 

3 단계 :

아파치 구성 (명령)에 최우선 htaccess로

sudo nano /etc/apache2/apache2.conf 

을 허용하고

AllowOverride All 

에 파일을 & 변화를 편집 www 폴더 용

4 단계 :

사용 아파치 모드 재 작성 (명령)

sudo a2enmod rewrite 

5 단계 : 의심스러운

다시 시작 아파치 (명령)

sudo /etc/init.d/apache2 restart 
+1

최고의 솔루션과 매력처럼 일했다 .. 덕분에 많이 – user2899728

+0

마침내! 효과적인 해결책. 'service apache2 restart' – FireBrand

+1

예이 솔루션은 codeigniter 3.x + 우분투에서 작동합니다. 16.04 –