如何创建重写规则,允许重写斜杠后面的东西,但有例外


How to create rewrite rule that allows to rewrite something right after slash with exceptions

我想创建这些重写规则:

来自:

www.something.com/name-of-some-product

:

www.something.com/index.php?site=name-of-some-product

但是我还需要使用图像和其他一些文件以及其他PHP文件

我有。htaccess:

RewriteCond %{REQUEST_URI}  !('.png|'.jpg|'.gif|'.jpeg|'.bmp|'.css)$
RewriteRule ^(.*)$ index.php?site=$1 [QSA]

问题是当我尝试加载文件像这样:

www.something.com/another_php_file.php?parameter=value

它不工作,因为我不知道如何避免重写PHP文件

试试这个规则,

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?site=$1 [QSA]