• 关于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。

  • 相关阅读:
    shell查看内存
    shell 终端字符颜色
    PHP获取一年有几周以及每周开始日期和结束日期
    PHP 计算当前时间是这一年的第几周
    laravel orWhere
    进程与线程的一个简单解释
    go cap和len的区别
    go 总结常用函数
    go append 函数常见操作
    php 字符串常用函数
  • 原文地址:https://www.cnblogs.com/linewman/p/9918869.html
Copyright © 2020-2023  润新知