URI上的htaccess重写器(有例外)


htaccess Rewriterule on URI with exceptions

我想重写以下URL:

http://www.web.de/productCat1->将Var productCat1传递到productCat.php
http://www.web.de/productCat1/product20->将Var productCat1+Var product20传递到products.php
http://www.web.de/shop->文件存在时不执行任何操作
http://www.web.de/contact->文件存在时不执行任何操作

到目前为止,我有这个:

Options +FollowSymLinks -MultiViews  
RewriteEngine On  
RewriteBase /  
# PHP to NO Extension  
RewriteCond %{REQUEST_FILENAME}.php -f  
RewriteCond %{REQUEST_URI} !/$  
RewriteRule ^(.*)$ $1'.php
#catch all products
RewriteCond %{REQUEST_URI} ^/([^/]+/[^/]+)/{0,1}$
RewriteRule ^([^/]+/[^/]+)/{0,1}$ /products.php?rw=1&url=$1/$2 [L,QSA]
#catch all categories
RewriteCond %{REQUEST_URI} !^/(shop|contact)$
RewriteRule ^([^/]+)$ /productCat.php?rw=1&url=$1/$2 [L,QSA]

经过几次尝试,我仍然收到500内部服务器错误。

尝试:

Options +FollowSymLinks -MultiViews  
RewriteEngine On  
RewriteBase /  
# PHP to NO Extension  
RewriteCond %{REQUEST_FILENAME}.php -f  
RewriteCond %{REQUEST_URI} !/$  
RewriteRule ^(.*)$ $1'.php
#catch all products
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+/[^/]+)/?$ /products.php?rw=1&url=$1 [L,QSA]
# catch all categories
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/? /productCat.php?rw=1&url=$1 [L,QSA]