2016-09-22 4 views
2

Codeigniter의 url에서 "index.php"를 제거하려고합니다. 베이스 URL에서 index.php를 제거하는 방법을 알고 싶습니다. example.com/controller.codeigniter remove index.php form url

하지만 난 CodeIgniter의 다른 프로젝트에 가지고 있기 때문에 example.com/folder/index.php/controller

같은 하위 폴더에 "index.php에"를 제거하는 방법을 모르겠어요. 그래서 두 번째 프로젝트는 하위 폴더에 업로드했습니다.

htaccess로

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

#modify 
RewriteEngine on 

RewriteCond $1 !^(index\.php|resources|robots\.txt) 

RewriteCond %{REQUEST_FILENAME} !-f 

RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule ^(.*)$ index.php?/$1 [QSA,L] 

RewriteBase/
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] 
RewriteRule ^(.*)$ http://%1/$1 [R=301,L] 

기본 URL에 대한 위의 프로그램. 그래서이 프로그램에서 바뀌게 될 것은 하위 폴더에서 작동합니다.

답변

0

쓰기 당신의 .htaccess 파일

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /folder/index.php [L] 
</IfModule> 

# END WordPress 

예에서이 코드를 생성합니다 example.com/folder/index.php/를 위의 코드 후 contorller

이 필요 index.php를

가 작동하고 ..

이 혼자
+0

고마워 ... 작동 중 – joy

+0

환영합니다 .... – Gagan

0

이 변수를 config.php에서 업데이트하십시오 ($config['index_page'] = '';). index.php

+0

당신의 URL에서 index.php를 제거되지 않습니다, 당신 같은 mod_rewrite는 어떤 형태를 사용해야합니다 쓰기 없습니다 허풍 파일을 올바르게 제거하도록 액세스하십시오. – killstreet

0
`Step:-1 Open the file config.php located in application/config path. Find and Replace the below code in config.php file. 

//이의 index.php에게 아래의 코드

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

// 제거를

$config['index_page'] = "" 

단계를 찾기 제거하여 CodeIgniter의 폴더로 이동 htaccess로 파일을 만들 -2.

경로 :

Your_website_folder/ 
    application/ 
    assets/ 
    system/ 
    user_guide/ 
    .htaccess <--------- this file 
    index.php 
    license.txt 

단계 : htaccess로 파일에 코드 아래에 쓰기 -3하는

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 

단계 : -4는 어떤 경우 uri_protocol의 기본 설정이 작동하지 않습니다 정확히. 이 문제를 그냥 응용 프로그램/설정에있는 파일 config.php를를 열고 발견하고 코드 교체 해결하기 위해 :

것은 // //

로 교체 아래 코드를

$config['uri_protocol'] = "AUTO" 

찾기

$config['uri_protocol'] = "REQUEST_URI" ` 
+0

선생님, 당신의 논리가 작동하지 않습니다 .. – joy

0

example.com/ 폴더와 동일한 단계를 거쳐 example.com/folder 폴더의 기본 URL에서 index.php를 제거하십시오. 즉, 편집/등 htaccess로, config 파일에서 index.php를 제거,