URL重写从/default.aspx到/ [英] URL Rewrite from /default.aspx to /
问题描述
我使用的URL Rewriting.NET工具,IIS 6,我有我的IIS中的Default.aspx默认页面内容设置。我试图做的是有/default.aspx提供301重定向到根目录(www.example.com/default.aspx - > www.example.com)。我试着关闭默认文档,都无济于事。
I'm using the URL Rewriting.NET tool with IIS 6. I've got my default page content set for default.aspx in IIS. What I'm trying to do is have /default.aspx provide a 301 redirect to the root directory (www.example.com/default.aspx -> www.example.com). I've tried turning off default documents, to no avail.
什么我希望做的是使用一对夫妇的URL Rewriting.NET规则来实现这一目标。有什么想法?
What I'm hoping to do is use a couple of URL Rewriting.NET rules to accomplish this goal. Any thoughts?
编辑:
对不起,我忘了澄清。如果我从/default.aspx重定向到/默认的文件打开(我想给他们留下的),然后我得到默认的无限循环 - > / - >默认
Sorry, I forgot to clarify. If I redirect from /default.aspx to / with default documents turned on (I'd like to leave them on) then I get an infinite loop of default -> / -> default
推荐答案
在最后,我清盘使用IIS 7的URL重写模块,它允许你正确地做到这一点重定向。
In the end I wound up using IIS 7 with the URL Rewrite module, which allows you to do this redirect properly.
编辑:
规则是
<rule name="Default Redirect" stopProcessing="true">
<match url="^default\.aspx$" />
<action type="Redirect" url="/" redirectType="Permanent" />
</rule>
你可以做到这一点与为每个文件夹一个单独的规则,也可以使用
you can do that with a separate rule for each folder, or you can use
<rule name="All Redirect">
<match url="^(.*\/)*default\.aspx$" />
<action type="Rewrite" url="{R:1}" />
</rule>
这篇关于URL重写从/default.aspx到/的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!