2009-10-22 2 views
1

본질적으로 이렇게하는 htaccess 파일을 작성하려고합니다.다른 유형으로 조건을 다시 쓰고 규칙을 다시 쓰면 htaccess를 사용할 수 있습니까?

if(requested file == "some-file.php" || requested file == "some-file2.php" || requested file == "some-file3.php") 
    then Rewrite to redirector.php?uri=some-file.php <- substitute requested file without passing any parameters 
else 
// existing rewrite conditions from silverstripe 
RewriteCond %{REQUEST_URI} ^(.*)$ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L] 

htaccess를 사용하면 가능합니까?

답변

0

내가 그 RewriteCond 년대 위는 상단에 3 개 RewriteRule들로 3 개 고유 요청 파일을 배치한다 할 필요를 생각 :

RewriteEngine On 
RewriteRule /(some-file.php) http://test.dev/redirector.php?uri=$1 [L] 
RewriteRule /(some-file2.php) http://test.dev/redirector.php?uri=$1 [L] 
RewriteRule /(some-file3.php) http://test.dev/redirector.php?uri=$1 [L] 

// rest of Rewrite Stuff 
0

이 규칙보십시오 :

RewriteRule ^(some-file\.php|some-file2\.php|some-file3\.php)$ redirector.php?uri=$1 
0

# if files are know, redirect and stop: 
RewriteRule ^(some-file|some-file2|some-file3)\.php$ redirector.php?uri=$1.php [QSA,L] 

# files that were not known go here: 
# existing rewrite conditions from silverstripe 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L] 

의 Nota : I

이 당신의 솔루션입니다 제거됨 :

RewriteCond %{REQUEST_URI} ^(.*)$ 

이는 쓸모가 없습니다. 당신이 "비어 있지"를 테스트하고 싶다면,이 있었어야 :

RewriteCond %{REQUEST_URI} !^$ 

올리비에