zoukankan      html  css  js  c++  java
  • apache 伪静态 (转)

     http://www.abc.com/product/test.php?sid=9000
    变成  http://www.abc.com/product/test_9000.shtml

    表达式是这样写的
    RewriteEngine On
       RewriteRule ^(.*)/product/test_(\d+)\.shtml$ $1/product/test.php?sid=$2

    然后一直以http://www.abc.com/product/test.php?sid=9000这个链接去测试,当初以为它会自动跳转为http://www.abc.com/product/test_9000.shtml,测试了很久都跳转不过去 以为是正则表达式写错了 改来改去都不行,后来百度了下:
    RewriteRule Pattern Substitution [flags]
    Pattern是一个作用于当前URL的perl兼容的正则表达式。"当前URL"是指该规则生效时刻的URL的值。它可能与被请求的URL截然不同,因为其他规则可能在此之前已经发生匹配并对它做了改动。
    Substitution是当原始URL与Pattern相匹配时,用来替代(或替换)的字符串。

    也就是说当用户以http://www.abc.com/product/test_9000.shtml来访问的时候,然后用^(.*)/product/test_(\d+)\.shtml$去匹配,如果匹配成功,就替换成$1/product/test.php?sid=$2去访问,当然在用户页面上显示的还是http://www.abc.com/product/test_9000.shtml,使用户认为访问的是静态网页。

    请务必保留此出处http://xinying.blog.51cto.com/441770/234713

  • 相关阅读:
    细菌(disease)
    素数路(prime)
    母亲的牛奶(milk)
    Counting Islands II
    Popular Products
    Binary Watch
    BZOJ 1822[JSOI2010]Frozen Nova 冷冻波
    尝试一下LLJ大佬的理论AC大法
    BZOJ 3626 [LNOI2014]LCA
    BZOJ 3319 黑白树
  • 原文地址:https://www.cnblogs.com/benio/p/1803275.html
Copyright © 2011-2022 走看看