asp.net的网站,要做成伪静态的网站。
下载了URLRewriter.dll,在BIN里引用了。
然后在web.config里进行了设置。
在IIS里也添加了扩展名.html网页里的连接还是原来的<a href="aaa.aspx?id=1">查看</a>
网站运行后,点连接地址栏还是aspx的。
是不是我网页里也需要改啊。
下载了URLRewriter.dll,在BIN里引用了。
然后在web.config里进行了设置。
在IIS里也添加了扩展名.html网页里的连接还是原来的<a href="aaa.aspx?id=1">查看</a>
网站运行后,点连接地址栏还是aspx的。
是不是我网页里也需要改啊。
<configuration>
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
</configSections>第二步,加入重写的规则节点:
如:
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/Sell/(.[0-9]*)\.html</LookFor>
<SendTo>~/Search/Search_Sell.aspx?id=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/Sell/Search_Sell\.aspx</LookFor>
<SendTo>~/Search/Search_Sell.aspx</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/Buy/(.[0-9]*)\.html</LookFor>
<SendTo>~/Search/Search_Buy.aspx?id=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/Buys/(.[0-9]*)\.html</LookFor>
<SendTo>~/Buys/Show.aspx?id=$1</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/(.[0-9]*)\.html </LookFor>
<SendTo>~/newsshow.aspx?id=$1 </SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>我的目录结构
default.aspx
newsshow.aspx
在根目录下,default.aspx里的新闻链接:<a href="newsshow.aspx?id=1">新闻名 </a> 我允许网站后,还是显示newsshow.aspx?id=1.是不是那弄错了?
<RewriterRule>
<LookFor>~/Sell/(.[0-9]*)\.html </LookFor>
<SendTo>~/Search/Search_Sell.aspx?id=$1 </SendTo>
</RewriterRule>
未使用伪静态的时候,
网页里的连接还是原来的 <a href="Search_Sell.aspx?id=1">查看 </a>
使用了伪静态以后,试着
网页里的连接直接写 <a href="sell1.html">查看 </a>sell后面的参数换成程序,使用规则后的访问直接替代伪前的访问
例:<a href='sell<%# DataBinder.Eval(DataItem.container...)%>.html'>查看 </a>