热搜:NVER node 开发 php

.htaccess 我写的重定向怎么不起作用

2024-09-15 13:30:02
.htaccess 我写的重定向怎么不起作用

.htaccess

RewriteRule ^products/list/([0-9]+) products/list.php?category_id=$1&%{QUERY_STRING} [L]
原先的有这个重定向,注释掉后 ***/products/list/10 这样的链接就不能访问了,打开后就好使

然后我再他下面写了个新的
RewriteRule ^products/list/category_id/(0-9]+)/parent_category/(0-9]+) products/list.php?category_id=$1&parent_category=$2 [L]
就是把 products/list?category_id=37&parent_category=35 成  products/list/category_id/37/parent_category/35

为什么我的新写的没作用??应该怎么写?

回复讨论(解决方案)

正规写法就行了

数字那两个地方写错了吧,(0-9]+) 应该是 ([0-9]+)

谢谢#2 这个简单地好使了,products/list/category_id/37/parent_category/35 这样的eurl好使了
现在问题是 
提交表单后,url里还是? & = 的形式。 products/list?category_id=37&parent_category=35(get提交表单)
怎么把url的形式给改掉,改成 products/list/category_id/37/parent_category/35 ??

这个就只能在php里面把所有链接地址改回来了