2016-11-16 2 views
0

모든 요청을 /index.php 라우터로 리디렉션하는 일부 mod_rewrite 구성이 있습니다. 예를 들어, 어떤 종류의 경로에 대해 새 라우터를 추가하고 싶습니다./path/action에 대한 요청은 /custom_engine/index.php 파일로 처리되어야합니다. 이런 식으로하는 방법?mod_rewrite에 새 라우터를 추가하는 방법

기존의 .htaccess :

<IfModule mod_rewrite.c> 
Options +FollowSymLinks 
RewriteEngine On 

# Get rid of index.php 
RewriteCond %{REQUEST_URI} /index\.php 
RewriteRule (.*) index.php?rewrite=2 [L,QSA] 

# Rewrite all directory-looking urls 
RewriteCond %{REQUEST_URI} /$ 
RewriteRule (.*) index.php?rewrite=1 [L,QSA] 

# Try to route missing files 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} public\/ [OR] 
RewriteCond %{REQUEST_FILENAME} \. (jpg|gif|png|ico|flv|htm|html|php|css|js)$ 
RewriteRule . - [L] 

# If the file doesn't exist, rewrite to index 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?rewrite=1 [L,QSA] 

</IfModule> 

답변

0
<IfModule mod_rewrite.c> 
Options +FollowSymLinks 
RewriteEngine On 

RewriteRule (path/action/)(.*) engine-v2/index.php [L,NC] 

# Get rid of index.php 
RewriteCond %{REQUEST_URI} /index\.php 
RewriteRule ^(path/action/)(.*) index.php?rewrite=2 [L,QSA] 

# Rewrite all directory-looking urls 
RewriteCond %{REQUEST_URI} /$ 
RewriteRule (.*) index.php?rewrite=1 [L,QSA] 

# Try to route missing files 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} public\/ [OR] 
RewriteCond %{REQUEST_FILENAME} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$ 
RewriteRule . - [L] 

# If the file doesn't exist, rewrite to index 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?rewrite=1 [L,QSA] 
</IfModule>