2013-08-06 1 views
2

두 개의 Codeigniter 사이트가 있습니다. 하나는 다른 사이트의 하위 디렉토리에 있습니다. 나는 두 htaccess 파일을 수정하여 index.php를 제거하는 데 도움이 필요하다.두 Codeigniter 사이트의 index.php 제거 및 하위 도메인 처리 (다른 하나가있을 때)

RewriteEngine On 
# Rewrite the main domain 
RewriteCond %{HTTP_HOST} !test.subdomain.domain.com 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

# Rewrite the sub domain 
RewriteCond %{HTTP_HOST} test.subdomain.domain.com 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^/(.*)$ /app_staging/index.php?/$1 [L] 

이것은 index.php를 제거입니다 :

첫 번째 사이트는 http://subdomain.domain.com이는 /home/sites/subdomain/www/html/에서 내 .htacess 파일입니다 /home/sites/subdomain/www/html/app_staging/

에, /home/sites/subdomain/www/html/

http://test.subdomain.domain.com 삶을 두 번째를 저장 첫 번째 사이트에서부터 모든 것이 정상입니다. 두 번째 사이트에서는 기본 컨트롤러 양식 http://test.subdomain.domain.com을로드 할 수 있지만 후속 페이지는 서버에서 404를 반환합니다. 다음 단계는 무엇입니까?

+0

당신이 시도 주어진 대답을 줄 수 있을까요? 모든 의견을 주시면 감사하겠습니다. –

+0

@HashemQolami의 답변을 잊어 버리지 않았습니다. 서버의 htaccess와 관련된 잠재적 인 문제를 조사하고 있습니다. 나는 당신의 대답이 한번 해결되는 방법을 알려 줄 것입니다. :) – Zoe

답변

3

두 개의 .htaccess 파일을 각각 자신의 루트 CI 폴더에 넣어야합니다.

개인적으로 요청한 파일 및/또는 폴더를 RewriteRule (으)로 처리하지 못하도록 제한하는 것을 선호합니다.

그래서, /home/sites/subdomain/www/html/에있는 첫 번째 파일 :

<IfModule mod_rewrite.c> 
    Options +FollowSymLinks 
    RewriteEngine on 
    RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico|public) 
    RewriteRule ^(.*)$ /index.php/$1 [L] 
</IfModule> 

그리고

/home/sites/subdomain/www/html/app_staging/에있는 다른 하나 :

<IfModule mod_rewrite.c> 
    Options +FollowSymLinks 
    RewriteEngine on 
    RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico|public) 
    RewriteRule ^(.*)$ /app_staging/index.php/$1 [L] 
</IfModule> 

참고 : 당신은 css 등을 추가해야합니다 (예 : public) ~ RewriteCond을 01로 처리하지 않으려면. 사이드 참고로

: 당신은 각 .htaccess 파일 내부에 다음과 같은 사용하여 디렉토리 목록을 방지 할 수 있습니다 :

<IfModule mod_autoindex.c> 
    Options -Indexes 
</IfModule> 
관련 문제