zoukankan      html  css  js  c++  java
  • 伪静态与重定向--RewriteBase

    RewriteBase用于设置目录级重写的基准URL,即所有的重定向都是基于这个URL。内部重定向可能看不出效果,但是在外部重定向(使用R flag后),如果不手动指定 / 为根目录,那么就会去整个磁盘路径查找。

    内部重定向:

    RewriteEngine On
    RewriteRule ^(.*).htm$   $1.html #注意$1前面没有加 /

      

    然后使用外部重定向:

    RewriteEngine On
    RewriteRule ^(.*).htm$   $1.html  [R]  #同样$1前面也并不加 /
    

      访问localhost/test.htm

    下面是指定根目录的情况:

    RewriteEngine On
    RewriteRule ^(.*).htm$   /$1.html  [R]  #注意$1前面加了 /
    

    访问localhost/test.htm  

    格式为:RewriteBase url-path

    实例:

    RewriteEngine On
    rewriteBase /test   #指定基准目录为/test
    RewriteRule ^(.*).htm$  $1.html  [R]  #注意$1前面没有加 /
    

     访问localhost/test.htm

  • 相关阅读:
    [手游新项目历程]-36- error: stray ‘357’ in program
    广告学(一)
    VMware的Unity模式
    poj3709
    poj1849
    bzoj2007
    bzoj3209
    bzoj2466,poj1222
    bzoj1016
    bzoj2186
  • 原文地址:https://www.cnblogs.com/-beyond/p/8325893.html
Copyright © 2011-2022 走看看