URLRewriter 可在本地主机上运行,但不能在服务器上运行
我在本地主机 (ASP.NET 4) 上使用了这些角色并且它有效:
<rewriter>
<rewrite url="~/man/(.+)" to="~/man/$1" processing="stop" />
<rewrite url="~/man/^(/.+(\.gif|\.png|\.jpg|\.ico|\.pdf|\.css|\.js|\.axd)(\?.+)?)$" to="~/man/$1" processing="stop" />
<rewrite url="~/files/^(/.+(\.gif|\.png|\.jpg|\.ico|\.pdf|\.css|\.js|\.axd|\.pdf|\.doc|\.ppt)(\?.+)?)$" to="~/files/$1" processing="stop" />
<rewrite url="~/man/" to="~/man/default.aspx" processing="stop"/>
<rewrite url="~/style/(.+)" to="~/style/$1" processing="stop" />
<rewrite url="~/images/(.+)" to="~/images/$1" processing="stop" />
<rewrite url="^(/.+(\.gif|\.png|\.jpg|\.ico|\.pdf|\.css|\.js|\.axd)(\?.+)?)$" to="$1" processing="stop" />
<rewrite url="~/register.aspx" to="~/register.aspx" processing="stop" />
<rewrite url="~/(.+)" to="~/default.aspx?pn=$1" />
</rewriter>
例如,http://localhost/myweb/foo
指的是 http://localhost/myweb/default .aspx?pn=foo
但在 Web 服务器上 http://myweb.xx/foo
显示'404 - 未找到文件或目录。'
I used these roles on the localhost (ASP.NET 4) and it works:
<rewriter>
<rewrite url="~/man/(.+)" to="~/man/$1" processing="stop" />
<rewrite url="~/man/^(/.+(\.gif|\.png|\.jpg|\.ico|\.pdf|\.css|\.js|\.axd)(\?.+)?)$" to="~/man/$1" processing="stop" />
<rewrite url="~/files/^(/.+(\.gif|\.png|\.jpg|\.ico|\.pdf|\.css|\.js|\.axd|\.pdf|\.doc|\.ppt)(\?.+)?)$" to="~/files/$1" processing="stop" />
<rewrite url="~/man/" to="~/man/default.aspx" processing="stop"/>
<rewrite url="~/style/(.+)" to="~/style/$1" processing="stop" />
<rewrite url="~/images/(.+)" to="~/images/$1" processing="stop" />
<rewrite url="^(/.+(\.gif|\.png|\.jpg|\.ico|\.pdf|\.css|\.js|\.axd)(\?.+)?)$" to="$1" processing="stop" />
<rewrite url="~/register.aspx" to="~/register.aspx" processing="stop" />
<rewrite url="~/(.+)" to="~/default.aspx?pn=$1" />
</rewriter>
For example, http://localhost/myweb/foo
refers to http://localhost/myweb/default.aspx?pn=foo
but on the web server http://myweb.xx/foo
says '404 - File or directory not found.'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
哪个版本的IIS有服务器,因为在II6中有不同的方式,在II7中有不同的方式。
Which version of IIS are there is Server because in II6 there is different way and in II7 There is different way.
检查您已在 Web.Config 的哪个部分配置了规则,因为 System.web 用于 VS 开发服务器(“Cassini”),IIS6 和 System.WebServer 用于 IIS7。
您还可以查看此处
Check in which section of your Web.Config you have configured your rules, as System.web is used for VS Development Server ("Cassini") and IIS6 and System.WebServer is used for IIS7.
You can also take a look here