我来看看 发表于 2023-03-14 18:52:54

IIS服务器下如何支持url重写(iis url 重写 多个端口)


    <p style="font-size: 14px; line-height: 40px; text-align: left; margin-bottom: 30px;">URL REWRITE,翻译过来就是URL重写,或者URL重定义在asp+iis的网站开发模式中,可以实现如将http://xxxxxx.cn/news.asp?id=220 变成http://xxxxxx.cn/220.html 的形式。</p>
    <p style="font-size: 14px; line-height: 40px; text-align: left; margin-bottom: 30px;">例如某条新闻的实际网址是http://xxxxxx.cn/news.asp?id=220 ,通过URL重写之后,我们就可以直接输入 http://xxxxxx.cn/220.html 的网址,来访问这条新闻。</p>
    <p style="font-size: 14px; line-height: 40px; text-align: left; margin-bottom: 30px;">对于iis服务器,要实现此项功能,需从 http://www.helicontech.com/download/ 网站上,下载Lite Version (free)免费版的软件,将此软件安装于服务器之后,在其安装目录上,找到配置文件httpd.ini,用记事本打开,输入相应的规则。</p>
    <p style="font-size: 14px; line-height: 40px; text-align: left; margin-bottom: 30px;">然后,在相应的站点上,ISAPI中,添加此组件,配置完成,功能生效2、URL_REWRITE的规则写法参考:当我需要将news.asp?id=234映射成news/234.html时,只需设置: RewriteRule /news/(\d+)\.html /news\.asp\?id=$1 </p>
    <p style="font-size: 14px; line-height: 40px; text-align: left; margin-bottom: 30px;">这样就把 /news/234.html 这样的请求映射成了 /news.asp?id=234 当有对/news/234.html的请求时:web服务器会把实际请求转发给/news.asp?id=234 </p>
    <p style="font-size: 14px; line-height: 40px; text-align: left; margin-bottom: 30px;">比对于某一个简单应用可以是:RewriteRule /news/(\d+)\.html /news/news\.php\?id=$1 这样就把 http://www.xxxxxx.com/news/234.html</p>
    <p style="font-size: 14px; line-height: 40px; text-align: left; margin-bottom: 30px;">映射到了 http://www.xxxxxx.com/news/news.php?id=234 一个更通用的能够将所有的动态页面进行参数映射的表达式是: 把 http://www.xxxxxx.cn/foo.php?a=A&amp;b=B&amp;c=C </p>
    <p style="font-size: 14px; line-height: 40px; text-align: left; margin-bottom: 30px;">表现成 http://www.xxxxxx.cn/foo.php/a/A/b/B/c/C RewriteRule (.*?\.php)(\?[^/]*)?/([^/]*)/([^/]*)(.+?)? $1(?2$2&amp;:\?)$3=$4?5$5: </p>
    <p style="font-size: 14px; line-height: 40px; text-align: left; margin-bottom: 30px;">3、使用URL重写功能的好处:首先,有助于增加网站的安全性,因为它隐藏了诸如asp php jsp等相关的服务器技术,以最原始的html文件形式,呈现于客户其次,在平台移植时,不会影响各页面的浏览如将news.asp?id=123转移news.php?id=123,即将asp平台转移php,如使用此URL重写,这个页面的网址就是news/123.html。</p>
    <p style="font-size: 14px; line-height: 40px; text-align: left; margin-bottom: 30px;">其它方面,方便URL引用,有助于搜索引擎的枚举。 注意服务器上不要乱设置</p>




不在那岸边 发表于 2026-09-22 14:52:18

说得很实在,没有夸大其词,这种真实分享太难得了

xlca 发表于 2026-09-23 02:08:14

完全赞同,我也是这么认为的,英雄所见略同~

472118477 发表于 2026-09-29 04:59:55

学习到了,之前一直没注意过这个点,受教了

哦啦1啦 发表于 2026-09-29 19:44:10

内容很干货,没有多余的废话,值得反复看

花倔 发表于 2026-10-02 19:56:16

这个分享太实用了,刚好能用到,感谢楼主!

叫什么好呢 发表于 2026-10-18 11:19:14

分析得很透彻,很多细节都说到点子上了~

福气满园 发表于 2026-10-23 14:58:20

楼主辛苦了,整理这么多内容,必须点赞收藏
页: [1]
查看完整版本: IIS服务器下如何支持url重写(iis url 重写 多个端口)