zoukankan      html  css  js  c++  java
  • htaccess转换httpd.ini方法及案例参考

    案例1:httpd.ini适合IIS使用,.htaccess适合Apache使用,nginx.conf适合Nginx使用

    转换前:httpd.ini

    [ISAPI_Rewrite]

    # 3600 = 1 hour

    CacheClockRate 3600

    RepeatLimit 32

    RewriteRule ^(.*)/view-(.*)-(.*).htm$ $1/view.php?s=$2&y=$3

    转换后:.htaccess(注意上面的红斜干)

    RewriteEngine on

    RewriteBase /

    RewriteRule ^(.*)view-(.*)-(.*).htm$ $1/view.php?s=$2&y=$3 

    案例2:从apache转到iis下,碰到.htacess转换httpd.ini,分享下方法。

    转换前:.htacess规则:

    RewriteEngine On

    RewriteCond %{HTTP_HOST} !^www.dedecms8.com$

    RewriteRule ^(.*)$ http://www.dedecms8.com/$1 [R=301,L,NC]

    RewriteBase /

    RewriteRule ^([^-/.\_-]+).html$ $1.php?

    RewriteRule ^([^-/.\_-]+)-op([^-/]+)-sor([^-/]+)-det([^-/]+).html$ $1.php?op=$2&sor=$3&det=$4

    RewriteRule ^([^-/.\_-]+)-op([^-/]+)-sor([^-/]+).html$  $1.php?op=$2&sor=$3

    RewriteRule ^([^-/.\_-]+)-sor([^-/]+).html$  $1.php?sor=$2

    RewriteRule ^([^-/.\_-]+)-op([^-/]+).html$  $1.php?op=$2

    RewriteRule ^([^-/.\_-]+)-page([^-/]+).html$  $1.php?page=$2

    RewriteRule ^([^-/.\_-]+)-op([^-/]+)-sor([^-/]+)-page([^-/]+).html$ $1.php?op=$2&sor=$3&page=$4

    转换后http.ini的写法:

     [ISAPI_Rewrite]

    RewriteRule /([^-/.\_-]+).html$ /$1.php?

    RewriteRule /([^-/.\_-]+)-op([^-/]+)-sor([^-/]+)-det([^-/]+).html$/$1.php?op=$2&sor=$3&det=$4

    RewriteRule /([^-/.\_-]+)-op([^-/]+)-sor([^-/]+).html$  /$1.php?op=$2&sor=$3

    RewriteRule /([^-/.\_-]+)-sor([^-/]+).html$  /$1.php?sor=$2

    RewriteRule /([^-/.\_-]+)-op([^-/]+).html$  /$1.php?op=$2

    RewriteRule /([^-/.\_-]+)-page([^-/]+).html$  /$1.php?page=$2

    RewriteRule /([^-/.\_-]+)-op([^-/]+)-sor([^-/]+)-page([^-/]+).html$/$1.php?op=$2&sor=$3&page=$4

     

    在.htacess转换httpd.ini转换结果汇中大家明显看到我们做了修改的几个地方,有颜色的部分就是修改过的,在.htacess转换httpd.ini转换中,就是要让apache和iis理解我们想要它做什么。上面代码不难看出:

    首先是对规则的定义要变,从rewrite_module变成isapi_rewrite。

    其次是路径要变,.htacess的路径是定义在头部中,而httpd.ini是定义在每行规则里,.htacess转换httpd.ini转

    换时将.htacess中^符号换成/,在独立页面前面加上路径/,以我自己理解这个/应该是相对目录的根目录。


  • 相关阅读:
    19. 星际争霸之php设计模式--迭代器模式
    18. 星际争霸之php设计模式--观察者模式
    17. 星际争霸之php设计模式--职责链模式
    16. 星际争霸之php设计模式--组合模式
    15. 星际争霸之php设计模式--策略模式
    14. 星际争霸之php设计模式--状态模式
    13. 星际争霸之php设计模式--正面模式
    12. 星际争霸之php设计模式--模板模式
    11. 星际争霸之php设计模式--备忘模式
    10. 星际争霸之php设计模式--原型模式
  • 原文地址:https://www.cnblogs.com/moqiang02/p/4061518.html
Copyright © 2011-2022 走看看