2011-11-03 223 views
2

客户的网站内容位于其网站上的子文件夹中,例如, www.customersite.com/content。它已经被移动到根文件夹,例如www.customersite.comIIS 301从子文件夹重定向到根文件夹

我们增加了IIS 301重定向到该网站的配置看起来像这样:

<rewrite> 
    <rules> 
    <rule name="Redirect to Root" stopProcessing="true"> 
    <match url=".*" /> 
     <conditions> 
     <add input="{HTTP_HOST}" pattern="^customersite.com/content/$" /> 
     </conditions> 
     <action type="Redirect" url="http://www.customersite.com/{R:0}" 
     redirectType="Permanent" /> 
    </rule> 
    </rules> 
</rewrite> 

该网站有一个看起来像www.customersite.com/content/链接?如果用户输入旧的www.customersite.com/content/?p=12地址,p = 12是否可以将重定向改为自动重定向到www.customersite.com/?p=12?如果是这样如何?

谢谢!

回答

3

我不能马上进行测试,但这应该工作:

<rewrite> 
    <rules> 
    <rule name="Redirect to Root" stopProcessing="true"> 
    <match url="^content/(.*)" /> 
     <conditions> 
     <add input="{HTTP_HOST}" pattern="^(www\.)?customersite.com$" /> 
     </conditions> 
     <action type="Redirect" url="http://{C:0}/{R:1}" redirectType="Permanent" /> 
    </rule> 
    </rules> 
</rewrite> 
0

www.customersite.com/content/?p=12的任何文件实际上都是IIS中的默认页面之一,因此该页面实际上类似于www.customersite.com/content/index.aspx假设你的默认文件是index.aspx,它可以是默认值等。

只需在此位置添加一个文件,并将代码设置为采取查询字符串并进行重定向,您也可以更改标题从代码状态背后,显示这是一个301