htaccess转换httpd.ini方法及案例参考

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

转换前:httpd.ini

[ISAPI_Rewrite]

#3600=1hour

CacheClockRate3600

RepeatLimit32

RewriteRule^(.*)<wbr style="padding:0px; margin:0px"><span style="color:rgb(51,51,51); font-family:Verdana,Arial,Tahoma; font-size:14px; line-height:25px; padding:0px; margin:0px"><span style="padding:0px; margin:0px; color:rgb(255,0,0)"><span style="padding:0px; margin:0px">/</span></span></span><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><span style="font-family:Verdana,Arial,Tahoma; color:#333333"><span style="font-size:14px; line-height:25px">view-(.*)-(.*)\.htm$$1/view</span></span><wbr style="padding:0px; margin:0px"><span style="font-family:Verdana,Arial,Tahoma; color:#ff0000"><span style="font-size:14px; line-height:25px">\</span></span><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><span style="font-family:Verdana,Arial,Tahoma; color:#333333"><span style="font-size:14px; line-height:25px">.php</span></span><wbr style="padding:0px; margin:0px"><span style="font-family:Verdana,Arial,Tahoma; color:#ff0000"><span style="font-size:14px; line-height:25px">\</span></span><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><span style="font-family:Verdana,Arial,Tahoma; color:#333333"><span style="font-size:14px; line-height:25px">?s=$2&amp;y=$3</span></span></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

转换后:.htaccess<wbr style="padding:0px; margin:0px"><span style="font-family:Verdana,Arial,Tahoma; color:#333333"><span style="font-size:14px; line-height:25px">(注意上面的红斜干)</span></span></wbr>

RewriteEngineon

RewriteBase/

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

<wbr style="padding:0px; margin:0px"></wbr>

案例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中^符号换成/,在独立页面前面加上路径/,以我自己理解这个/应该是相对目录的根目录。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值