做伪静态,URL重写,请盆友们指导写一下正则。伪静态页面如下:
分类: http://www.xxx.com/sakura/c-28.html
http://www.xxx.com/sakura/c-28_15.html
http://www.xxx.com/sakura/c-28_15_23.html
类别有三级,一个数字ID代表一级。产品: http://www.xxx.com/sakura/p-1058.html实际页面如下:
分类页:http://www.xxx.com/index.php?main_page=categories&cPath=28
http://www.xxx.com/index.php?main_page=categories&cPath=28_15
http://www.xxx.com/index.php?main_page=categories&cPath=28_15_23
产品页:http://www.xxx.com/index.php?main_page=product_info&products_id=196
在.htaccess里面肿么写正则匹配呢
RewriteEngine on
RewriteRule ^(.*)-p-(.*).html$ index.php?main_page=product_info&products_id=$2(这个是错的,不对)
分类: http://www.xxx.com/sakura/c-28.html
http://www.xxx.com/sakura/c-28_15.html
http://www.xxx.com/sakura/c-28_15_23.html
类别有三级,一个数字ID代表一级。产品: http://www.xxx.com/sakura/p-1058.html实际页面如下:
分类页:http://www.xxx.com/index.php?main_page=categories&cPath=28
http://www.xxx.com/index.php?main_page=categories&cPath=28_15
http://www.xxx.com/index.php?main_page=categories&cPath=28_15_23
产品页:http://www.xxx.com/index.php?main_page=product_info&products_id=196
在.htaccess里面肿么写正则匹配呢
RewriteEngine on
RewriteRule ^(.*)-p-(.*).html$ index.php?main_page=product_info&products_id=$2(这个是错的,不对)
RewriteRule ^(.*)-p-(\d+).html$ index.php?main_page=product_info&products_id=$2试试
这里我写的只是举个例子。
实际页面:http://www.xxx.com/index.php?main_page=product_info&products_id=196
伪静态页面:http://www.xxx.com/sakura/p-1058.html按您这样写应该也是错的吧。
这样是可以的,不过我不是很熟,不知道这样写的是不是规范或者简洁。