很多网站做好了,最后卡在伪静态规则上去不知道怎么办,每个环境的伪静态规则是不一样,而一般程序只提供一种伪静态规则,那么我们要怎么办呢?请看站长啦推出伪静态规则转换之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
[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中^符号换成/,在独立页面前面加上路径/,以我自己理解这个/应该是相对目录的根目录。
版权与免责声明:
凡注明稿件来源的内容均为转载稿或由网友用户注册发布,本网转载出于传递更多信息的目的;如转载稿涉及版权问题,请作者联系我们,同时对于用户评论等信息,本网并不意味着赞同其观点或证实其内容的真实性;

![英雄棋士团(预下载)?=$bqr['banben']?>](http://shouyouimg.cnzzla.com/d/file/shouyoupic/yingxiongqishituanyuxiazai.jpg)
![美食小当家?=$bqr['banben']?>](http://shouyouimg.cnzzla.com/d/file/shouyoupic/meishixiaodangjia.png)
![2047?=$bqr['banben']?>](http://shouyouimg.cnzzla.com/d/file/shouyoupic/2047.jpg)
![荣誉指挥官(预下载)?=$bqr['banben']?>](http://shouyouimg.cnzzla.com/d/file/shouyoupic/rongyuzhihuiguanyuxiazai.png)
![繁荣美食市场物语?=$bqr['banben']?>](http://shouyouimg.cnzzla.com/d/file/shouyoupic/fanrongmeishishichangwuyu.jpg)
![夸克浏览器 v4.2.1.138 好用的手机浏览器?=$bqr['banben']?>](http://shouyouimg.cnzzla.com/d/file/appimg/202007/kuakezuolanqi.jpg)
![移动办公软件 OfficeSuite Premium v10.18.28716 内购解锁版?=$bqr['banben']?>](http://shouyouimg.cnzzla.com/d/file/appimg/202007/yidongbangongruanjian.jpg)
![乐秀视频编辑器 VideoShow v8.8.4 内购解锁版?=$bqr['banben']?>](http://shouyouimg.cnzzla.com/d/file/appimg/202007/lexiushipinbianjiqi.png)
![X 浏览器 v3.3.9 一款小巧的安卓浏览器?=$bqr['banben']?>](http://shouyouimg.cnzzla.com/d/file/appimg/202007/x.jpg)
![安卓密码管理软件 Enpass v6.4.5.368 内购解锁版?=$bqr['banben']?>](http://shouyouimg.cnzzla.com/d/file/appimg/202007/anzhuomimaguanliruanjian.jpg)
![差分复制同步 FastCopy-M v3.6.3.51 绿色便携版?=$bqr['banben']?>](http://shouyouimg.cnzzla.com/d/file/softimg/FastCopy3.png)
![多标签页拓展 Clover v3.5.2 Build 19809 精简绿色版?=$bqr['banben']?>](http://shouyouimg.cnzzla.com/d/file/softimg/Clover.png)
![文件重命名 Advanced Renamer v3.85 Lite 绿色便携版?=$bqr['banben']?>](http://shouyouimg.cnzzla.com/d/file/softimg/Advanced_Renamer.png)
![网络防火监控 GlassWire Elite v2.1.166 绿色便携版?=$bqr['banben']?>](http://shouyouimg.cnzzla.com/d/file/softimg/GlassWire.png)
![影音播放器 Daum Potplayer v1.7.20538 美化便携版?=$bqr['banben']?>](http://shouyouimg.cnzzla.com/d/file/softimg/PotPlayer.png)