IIS 301从子文件夹重定向到根文件夹
客户将其网站内容放在其网站的子文件夹中,例如 www.customersite.com/content。此后它已被移至根文件夹,例如 www.customersite.com
我们已向站点配置添加了 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/?p =12 如果用户输入旧的 www.customersite.com/content/?p=12 地址,是否可以将重定向更改为自动重定向到 www.customersite.com/?p=12?如果是这样怎么办?
谢谢你!
A customer had their website content in a subfolder on their site e.g. www.customersite.com/content. It has since been moved to the root folder e.g. www.customersite.com
We've added a IIS 301 redirect, to the site config that looks like this:
<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>
The site had links that looked like www.customersite.com/content/?p=12 would it be possible to change the redirect to automatically redirect to www.customersite.com/?p=12 if a user types in the old www.customersite.com/content/?p=12 address? If so how?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我现在无法测试它,但这应该有效:
I'm not able to test it right now, but this should work:
任何 www.customersite.com/content/?p=12 实际上都是 IIS 中的默认页面之一,因此该页面实际上类似于 www.customersite.com/content/index.aspx?p=12假设您的默认文件是index.aspx,它可能是默认文件等。
只需在此位置添加一个文件并设置后面的代码以获取查询字符串并执行重定向,您还可以从后面的代码更改标头状态以显示此是301。
Any file which is www.customersite.com/content/?p=12 will actually be one of the default pages in IIS, so the page will really be something like www.customersite.com/content/index.aspx?p=12 assuming your default file is index.aspx it could be default etc.
Just add a file at this location and set the code behind to take the query string and do a redirect, you can also change the header state from the code behind to show this is a 301.