一开始IIS配置伪静态,参考了
/simoje/p/4764392.html
/Fooo/archive//09/24/2189744.html
也是各种尝试没能实现,后来我看到URLRewrite组件,最后成功实现了伪静态,下面附上配置步骤。
参考:
/sys/Windows/66641.htm
首先安装URLRewrite组件,下载地址,你也可以去官网下载
/
安装之后,打开IIS会看到URL Rewrite如图:
现在我们写一个url重写规则文件,
<ifmodule mod_rewrite.c>RewriteEngine RewriteRule ^index\.html$ /index.aspx [L]</ifmodule>1
2
3
4
这个代码块一个非常简单的功能是,index.html页面请求会访问我们的index.aspx。根据每个网站的的需要可以新增RewriteRule。文件后缀名为htaccess,保存。
双击URL Rewrite,点击“Import Rules…”如图:
选择我们刚才保存的htaccess文件 Import。这样你访问网站输入index.html,出来的就是index.aspx页面。
最后你会发现,网站的web.config文件会多出一段代码
<rewrite> <rules> <rule name="Imported Rule 1" stopProcessing="true"> <match url="^index\.html$" ignoreCase="false" /> <action type="Rewrite" url="/index.aspx" /> </rule> </rules></rewrite>1
2
3
4
5
6
7
8
那我们直接在web.config配置文件中加入代码
<rewrite> <rules> <rule name="Imported Rule 1" stopProcessing="true"> <match url="^index\.html$" ignoreCase="false" /> <action type="Rewrite" url="/index.aspx" /> </rule> <rule name="Imported Rule 8" stopProcessing="true"> <match url="^default\.html$" ignoreCase="false" /> <action type="Rewrite" url="/index.aspx" /> </rule> </rules></rewrite>1
2
3
4
5
6
7
8
9
10
11
12
然后访问default.html,出来的就是index.aspx页面。那么再接下来项目加页面时,在web.config里加入代码就可以了。