2013-08-05 111 views
0

我在我的.htaccess多mod_rewrite的規則在.htacess

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+)$ /rewrite/index.php?pages=$1 [L] 

偉大的工程重寫所有的文件和目錄不存在以下。 但現在我需要做另一個更具體的重寫

條件應該是「如果請求的URI不存在,並以參加者/ /結束」,則應用重寫規則^(。+)$ /rewrite/attendees.php? pages = $ 1 [L]

這怎麼可能適用?

起初我以爲它會在上市的順序讀取,從而嘗試:

RewriteCond %{REQUEST_FILENAME} employee [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+)$ /rewrite/attendees.php?pages=$1 [L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+)$ /rewrite/index.php?pages=$1 [L] 

但失敗...


解決在使用本:

RewriteCond %{REQUEST_URI} (employee) [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+)$ /rewrite/employee.php?pages=$1 [L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+)$ /rewrite/index.php?pages=$1 [L] 

乾杯!

+0

的[在.htaccess多模\ _rewrite規則(可能重複http://stackoverflow.com/questions/10089097/multiple-mod-rewrite-rules-in -htaccess) – djf

回答

0

只需要添加另外RewriteCond

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} attendees/$ 
RewriteRule ^(.+)$ /rewrite/index.php?pages=$1 [L]