在.htaccess中添加例外

时间:2012-09-03 15:39:45

标签: .htaccess 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>

发送

requests /index.php/path/to/module/ to "index.php"
 AcceptPathInfo On

@ todo这在某些情况下可能无效

FileETag Size

现在,我想将脚本与这个htaccess集成......这是脚本所说的......“添加exception来执行/ cometchat目录中的所有index.php文件及其子服务器上的目录。“

那么,如何添加异常来执行此目录中的Index.php,同时不妨碍现有的.htaccess code ...

1 个答案:

答案 0 :(得分:0)

您希望将您的例外置于其他规则之前,以确保其不会受到干扰。

这样的东西
RewriteRule ^cometchat/(.+)?$ cometchat/$1 [L]
RewriteEngine On

之后立即

这应该直接执行cometchat中的所有文件,而不对其强加其他规则。


另一种方法是使用负面模式as demonstrated here