의 Codeigniter에서 index.php를 제거하는 mod_rewrite Codeigniter 응용 프로그램은 일반적으로 mod_rewrite를 사용하여 URL에서 index.php
문자열을 제외합니다. 두 개의 Codeigniter 응용 프로그램이 동일한 도메인 내에 있습니다. 하나의 Codigniter 응용 프로그램이 웹 루트 폴더에 있고 다른 Codigniter 응용 프로그램이 웹 루트 폴더의 하위 폴더에 있습니다.하위 디렉토리
CodeIgniter의 응용 프로그램 1 :
http://domain.com/index.php
CodeIgniter의 응용 프로그램 2 (방문 페이지 응용 프로그램) :
http://domain.com/land/index.php
두 CodeIgniter의 응용 프로그램은 각 원자 그리고 그들 사이에 파일을 공유하지 않습니다. Codeigniter 프레임 워크의 모든 파일은 public_html/
이고 다시 public_html/land/
입니다. 그래서 index.php
이라는 URL을 /
폴더의 주소로 제외하고 /land/
하위 폴더의 문자열을 제외해야합니다.
루트 폴더의 .htaccess 파일은 Codeigniter wiki에서 널리 권장되는 mod_rewrite 규칙 (아래 코드)을 사용하며이 규칙 집합은 루트 Codeigniter 응용 프로그램 (응용 프로그램 1)에서 잘 작동합니다. 이 규칙은 웹 루트 폴더에 있습니다.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Rename 'application' to your applications folder name.
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>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 /index.php
</IfModule>
규칙의 위의 세트는 루트 CodeIgniter의 응용 프로그램의 URL에서 index.php
을 제거하는 문제가 없습니다. 그러나이 규칙 세트는 public_html/land/.htaccess
의 mod_rewrite 규칙을 실행할 수있는 것으로 보이지 않습니다.
public_html/.htaccess
에서 mod_rewrite 규칙을 제거하면 public_html/land/.htaccess
의 mod_rewrite 규칙이 평가되기 시작합니다.
/land/
하위 폴더에 액세스하려는 URL의 특수한 경우를 처리하도록 public_html/.htaccess
에서 mod_rewrite 규칙을 변경하는 방법이 있습니까?
나는 최상의 해결책은 의 mod_rewrite 규칙이 하위 폴더가 URL에서 처리 될 때 실행할 수 있도록 public_html/.htaccess
의 mod_rewrite 규칙을 변경하는 것일 수 있다고 생각합니다. 나는 어떤 제안이든 열려 있습니다.
"선생님은 왜 하위 도메인을 사용하지 않으시겠습니까?"라는 질문에 선제 적으로 대답합니까? 1. SSL 인증서에 비용 절약. 2) 비 기술적 인 사용자는 기본 도메인 이름을 마케팅하기 위해 하위 도메인과 혼동되기도합니다.
"프레임 워크에서 동일한 파일을 사용하도록 Codeigniter 응용 프로그램을 결합하는 이유는 무엇입니까?"에 대한 선제 적 대답은 무엇입니까? 프레임 워크 파일을 복제하면 버전 관리 저장소를 쉽게 분리 할 수 있습니다.
폴더를 RewriteBase에 다음과 같이 추가하십시오. RewriteBase/land/ – Drewdin