关于TP 特殊页面伪静态规则的编写 研究实现

关于TP 特殊页面伪静态规则的编写 研究实现

首先 场景是shopnc 下有部分的伪静态页面跳转。我们查看  .htaccess

如下:
# apache ,iis 伪静态规则
RewriteRule ^goods-([0-9]+)(-?)([0-9]*).html$ index.php?act=goods&goods_id=$1
RewriteRule ^groupbuy-([0-9]+)-([0-9]+).html$ index.php?act=show_groupbuy&op=groupbuy_detail&group_id=$1&id=$2
RewriteRule ^article-([0-9]+).html$ index.php?act=article&article_id=$1
RewriteRule ^store-([0-9]+).html$ index.php?act=show_store&id=$1
RewriteRule ^store-([0-9]+)-([0-9]+).html$ index.php?act=show_store&id=$1&mfid=$2
RewriteRule ^activity-([0-9]+)-([0-9]*).html$ index.php?act=activity&activity_id=$1&nav_id=$2
RewriteRule ^store_nav-([0-9]+)-([0-9]+).html$ index.php?act=show_store&id=$1&article=$2
RewriteRule ^document-([a-zA-Z_]+).html$ index.php?act=document&code=$1
RewriteRule ^coupon_info-([0-9]+)-([0-9]+).html$ index.php?act=coupon_store&op=detail&coupon_id=$1&id=$2

那么好了想当然了,我们可以直接复制这个规则 到TP下使用,但是问题出现了
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]
 
#RewriteRule ^article-([0-9]+).html$ article/index/article_id/$1

RewriteRule ^(.*)/article-([0-9]+).html$ $1/article/index/article_id/$2

如上 :
RewriteRule ^article-([0-9]+).html$ article/index/article_id/$1 我们访问Http://蛋疼啊.com/article-22.html你猜什么,TP报错,无法找到 article-22.html 模块。说明没有匹配嘛。

然后务必纠结研究了 RewriteRule ^(.*)/article-([0-9]+).html$ $1/article/index/article_id/$2 这个规则可以,已经吐血了。

其他页面类推.

当然,是不是可以研究下TP的内置功能,路由等来实现,这个估计就更麻烦了。

PS: .htaccess处理的重写 ,抓包抓不到真实的URL。

posted @ 2016-05-06 17:21 Newman·Li 阅读( ...) 评论( ...) 编辑 收藏
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值