2013-01-04 4 views
1

두 가지 다른 .htaccess 파일을 가지고 있으며 서로 결합 할 때 함께 작동하지 않습니다.두 개의 .htaccess 파일을 다시 작성하십시오.

첫 번째 날 www.mydoman.com/test 입력하고 사용의 확장 오프 두 번째 파일 삭감

RewriteRule ^([A-Za-z0-9-_]+)/?$ index.php?subclass=$1 [NC,L] 
RewriteRule ^.* index.php [NC,L] 

을 www.mydomain.com/index.php?page=test 의미가 있습니다 .html 중에서 및 .PHP 파일에는 하나의 .htaccess에서 함께 작동하는이 두 가지를 허용 할 수있는 방법이 있나요 www.mydomain.com/about이 www.mydoman.com/about.php

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 

RewriteBase /cl_clone 

## hide .php extension 
# To externally redirect /dir/foo.php to /dir/foo 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] 
RewriteRule^%1 [R,L,NC] 

## To internally redirect /dir/foo to /dir/foo.php 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule^%{REQUEST_URI}.php [L] 

# e.g. example.com/foo will display the contents of example.com/foo.html 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}.html -f 
RewriteRule ^(.+)$ $1.html [L,QSA] 

의 insted 사용할 수 있습니다 파일?

답변

1

맨 위에는 리디렉션 규칙이 있고, 요청이 끝나면 php 또는 html 확장자를 추가하는 규칙이 2 세트 있습니다 (그러한 파일이있는 경우). 그런 다음 다른 규칙은 index.php에 대한 라우팅을 수행합니다.

해결해야 할 몇 가지 사항이 있습니다. 요청에 cl_clone이 없으므로 (예 : www.mydomain.com/about, cl_clone이 아님) 다시 작성하는 기본 URL이 /cl_clone입니다. 두 경우 모두에서 제대로 작동하지 않는 것으로 보입니다.

그래서 제거하고 싶을 것입니다.

그렇지 않으면 단순히 다른 규칙의 맨 아래에 index.php 라우팅 규칙을 추가하면됩니다. 당신은 아마도, 추가 조정이 추가해야 할 수 있습니다 :

RewriteRule ^([A-Za-z0-9-_]+)/?$ index.php?subclass=$1 [NC,L] 
RewriteCond %{REQUEST_URI} !index.php 
RewriteRule ^.* index.php [NC,L] 

또는 변경하여 RewriteBase /cl_cloneRewriteBase /

관련 문제