2010-12-23 2 views
0

QUERY_STRING을 (를) 사용하면서 URL에서 index.php 및 .php를 숨길 수 있습니다. 지금, 나는 성공적으로 index.php에 숨어있어QUERY_STRING 사용 중에 URL에서 index.php 및 .php 숨기기

내 htaccess로에서 다음과 같이 (제외 특정 디렉토리에 액세스 할 때) : 나는 특정 기능을 가지고 있기 때문에

RewriteEngine On 
RewriteCond $1 !^(codex|_core|admin|index\.php) [NC] 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

내가 같은이 일을 해요 로그인/로그 아웃/등록, 페이지 역할 : example.com/login

그러나 나는 또한 예를 들어, PHP 함수의 무리와 함께 하나의 파일 안에있는 혜택을 볼 수없는 정적 페이지가 있습니다. co.kr/terms-and-conditions.php

제복을 입은 채로, example.com/login을 위반하지 않고 해당 URL을 example.com/terms-and-conditions으로 변환하려면 어떻게해야합니까? 이것은 가능한가? 나는 .php 제거를 추가하려고 시도했다. index.php 제거에 대한 재 작성 (index.php에서 .php를 분명히 제거함)은 아무런 쓸모가 없다.

나는 here에 위치한 솔루션을 사용해 보았지만 example.com/login을 깨뜨렸다. 기능/쿼리를 사용하고 있기 때문에 가정합니다. 거기에서 바꿀 필요가있는 작은 것이 있습니까?

답변

0

알아 냈어! 뒤돌아 보면 두 가지를 결합해야했습니다. :)

RewriteEngine On 

# remove .php; use THE_REQUEST to prevent infinite loops 
RewriteCond %{HTTP_HOST} ^www\.domain\.com 
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP 
RewriteRule (.*)\.php$ $1 [R=301] 

RewriteCond $1 !^(codex|_core|admin|index\.php) [NC] 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

# remove slash if not directory 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} /$ 
RewriteRule (.*)/ $1 [R=301] 

# add .php to access file, but don't redirect 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteCond %{REQUEST_URI} !/$ 
RewriteRule (.*) $1\.php [L]