zoukankan      html  css  js  c++  java
  • 关于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。

  • 相关阅读:
    以用户名注册来分析三种Action获取数据的方式
    Struts2中的OGNL详解 《转》
    Module 'null' not found异常解决办法
    struts标签<logic:iterate>的用法
    struts2的核心和工作原理 <转>
    jstl标签怎么实现分页中下一页
    forward 和redirect
    forward 和redirect的区别
    今天早上起来就想着要问问龙虎有圆通没
    昨天晚上回来弄了两个皮蛋吃
  • 原文地址:https://www.cnblogs.com/linewman/p/9918869.html
Copyright © 2011-2022 走看看