我有以下脚本:
Options +FollowSymLinks
RewriteEngine On
# PATH
RewriteBase /bbv/
# ERROR RULE
ErrorDocument 404 /bbv/404.php
# WORKS
RewriteRule ^home$ index.php
RewriteRule ^contact$ contact.php
RewriteRule ^(.*)\.html$ template_cat.php?cat=$1 [L]
# THIS DOES NOT WORK
RewriteRule ^(.*)\(.*)-(.*)$ template_prod.php?cat=$1&prod=$2&id=$3 [L]
RewriteRule ^(.*)$ template_cat.php?cat=$1 [L]
我希望如下: localhost / bbv / category 和 localhost / bbv / category / product-id < / em>的
错误在哪里? TX。
答案 0 :(得分:2)
使用此代码:
# ERROR RULE
ErrorDocument 404 /bbv/404.php
Options +FollowSymLinks
RewriteEngine On
# PATH
RewriteBase /bbv/
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
# WORKS
RewriteRule ^home$ index.php [L]
RewriteRule ^contact$ contact.php [L]
RewriteRule ^([^.]+)\.html$ template_cat.php?cat=$1 [L,QSA]
RewriteRule ^([^/]+)/([^-]+)-(.+)$ template_prod.php?cat=$1&prod=$2&id=$3 [L,QSA]
RewriteRule ^(.+)$ template_cat.php?cat=$1 [L,QSA]