.htaccess RewriteCond问题

时间:2010-12-12 21:19:33

标签: php .htaccess mod-rewrite

我的.htaccess中有这个:

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !/includes
RewriteCond %{REQUEST_URI} !/images
RewriteRule (.*) index.php

它通过index.php重定向所有页面,但includes和images文件夹除外。这是使用例外的正确方法吗?还有一种方法可以在一条RewriteCond规则上使用例外而不是在单独的一条线上使用这些例外吗?

1 个答案:

答案 0 :(得分:2)

对于异常这很好,但你可以在之间添加一个^!和/使它说“开始于”。至于组合它们,您可以执行以下操作:

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !/(includes|images)
RewriteRule (.*) index.php