我想重写以下网址:
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内部服务器错误。
答案 0 :(得分:0)
尝试:
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]