2012-03-21 203 views
0

好吧,我有以下.htaccess,它的工作原理,但我似乎可以改变它的方式,我需要它。.htaccess - 重写规则

这里是当前的.htaccess

RewriteEngine on 
RewriteCond $1 !^(index\.php|admin|system|images|tpl|js|lib|favicon\.ico|robots\.txt) 
RewriteRule ^(.*)$ /index.php?tpl=$1 [L] 


Options +FollowSymlinks 

我需要添加以下

RewriteRule ^(.*)/(.*)$ /index.php?cat=$1&tpl=$2 [L] 

所以我想知道我如何才能这一规则的工作?因为当我添加它没有。

+0

'[L]'表示*最后*。因此,如果第一次重写工作,没有其他人会为同一请求做。 – kirilloid 2012-03-21 22:16:57

回答

0

所以,如果你想添加一个规则,将处理所有的请求,除了第一个匹配的RewriteCond这些将被拆分成/?

我认为像这样的东西会起作用。请注意,在您的重写条件中,我将$ 1更改为$ {REQUEST_URI}

RewriteEngine on 
RewriteCond ${REQUEST_URI} !^(index\.php|admin|system|images|tpl|js|lib|favicon\.ico|robots\.txt) 
RewriteRule ^(.*)$ /index.php?tpl=$1 [L] 

RewriteRule ^([^/]*)/?(.*)?$ /index.php?cat=$1&tpl=$2 [L] 

Options +FollowSymlinks