文件夹中的.htaccess规则无效

时间:2014-12-27 17:15:20

标签: php apache .htaccess mod-rewrite

我有一个名为products的文件夹,我想用htaccess重写(htaccess放在文件夹中)

我使用的代码是

Options +FollowSymLinks -MultiViews
RewriteEngine On 
RewriteBase /products/

RewriteRule ^([a-z]+)/([a-z]+)/([0-9]+)$ index.php?product=$1&brand=$2&page=$3 [L,QSA]

现在我想要实现的是 我想转换

abc.com/products/index.php?product=toshiba-laptop&brand=toshiba&page=3

abc.com/products/toshiba-laptop/toshiba/3

1 个答案:

答案 0 :(得分:0)

解决自己感谢代码使用是

RewriteRule ^([^/.]+)/?$ index.php?cat=$1 [L]
RewriteRule ^([^/]*)/([a-z-]+)$ index.php?cat=$1&brand=$2 [L]
RewriteRule ^([^/]*)/([0-9]+)$ index.php?cat=$1&page=$2 [L]
#RewriteRule ^([^/]*)/([a-z-]+)/(.*)/$ index.php?cat=$1&brand=$2&page=$3 [L]
RewriteRule ^([a-z]+)/([a-z]+)/([0-9]+)$ index.php?cat=$1&brand=$2&page=$3 [L,QSA]