2013-08-07 60 views
1

我想將所有的URI管道化爲index.php,除非特定的文件存在於根目錄中。我有點難倒當談到從這個排除的index.php作爲當然它不會全部規則使用RewriteRule排除文件名

Options +FollowSymLinks -Indexes 
RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} != "index/.php" // I'm not sure on the syntax here 
RewriteRule ^(.*)$ $1.php [L] 

RewriteRule ^([^/]*)(.*)$ index.php?category=$1&post=$2 [L,QSA] 
符合我的最後一個catch

回答

1

通過添加附加條件到最後規則

RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^([^\.]+)$ $1.php [L] 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^/]*)(.*)$ index.php?category=$1&post=$2 [L,QSA] 
解決