凹丫丫网络社区's Archiver

oyaya 发表于 2008-1-10 21:02

ASP的URL重写技术 IIS的ISAPI

<P>首先下载ISAPI ReWrite(<FONT color=#ff0000>如果发现下载不了,请提示本空间更新</FONT>), </P>
<P>这个嘛,百度一下就可以找到了,<BR>解压后,会有httpd.ini、httpd.parse.errors、mtbnotif.dll、Rewrite.dll,四个文件<BR>我们要用到的只有<FONT color=#0000ff>Rewrite.dll</FONT>和<FONT color=#0000ff>httpd.ini</FONT>两个文件,其它两个也放着,别删了,呵呵……<BR><FONT color=#0000ff>把Rewirte.dll添加到IIS上去</FONT>,<BR>选择要添加的虚拟目录,点击鼠标右键,选择“属性”,点击“ISAPI筛先器”,点击“添加”,如图:</P>
<P>[attach]412[/attach]</P>
<P>之后,编辑httpd.ini文件:<BR>本网站是用ASP开发的,比如查看新闻的时候,<BR>一般都是这样的URL <FONT color=#ff6600>http://localhost/news/newsview.asp?id=123</FONT>,现在我们用URL 重写成<FONT color=#3366ff>http://localhost/news/news_123.html</FONT>,<BR>就要在httpd.ini文件中添加RewriteRule 重写规则,<BR>[ISAPI_Rewrite]<BR># 3600 = 1 hour<BR>CacheClockRate 3600<BR>RepeatLimit 32<BR>#&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;要输出的路径&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; #要重写的路径 (\d+) 就是任意整型&nbsp; &nbsp;$1 就是要代替的第一个参数,如果有第二个,可以用$2,如此类推<BR><FONT color=#3366ff>RewriteRule /client/news_(\d+)+\.html /client/newsView\.asp\?id=$1</FONT><BR>最后,还要在asp网页上把超级链接改过来,<BR>以前这样的,<BR><FONT color=#ff6600>&lt;a href="client/newsView.asp?id=&lt;%=NewsRS("ARTICLE_ID")%&gt;"&gt;&lt;%=NewsRS("AR_TITLE")%&gt;&lt;/a&gt;</FONT><BR>要改为<BR><FONT color=#3366ff>&lt;a href="client/news_&lt;%=NewsRS("ARTICLE_ID")%&gt;.html"&gt;&lt;%=NewsRS("AR_TITLE")%&gt;&lt;/a&gt;</FONT><BR>就OK了,试试看!!<BR><BR>实现结果 就是将<A href="http://www.oyaya.cn/news.asp?id=123" target=_blank><A href="http://www.oyaya.cn/news.asp?id=123" target=_blank><FONT color=#0000ff>www.oyaya.cn/news.asp?id=123</FONT></A></A><BR>显示为&nbsp; &nbsp;<A href="http://www.oyaya.cn/news-123.html" target=_blank><A href="http://www.oyaya.cn/news-123.html" target=_blank><FONT color=#0000ff>www.oyaya.cn/news-123.html</FONT></A></A> </P>

TroyHorse 发表于 2008-4-13 13:52

学习了,楼主辛苦了!!!

whyben 发表于 2008-5-7 16:34

好好学习,天天发帖!全心全意把社区顶起来!!!:)

稻草人 发表于 2008-5-30 14:56

有自己的服务器就是方便

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.