ASP.NET IIS7 的永久 301 重定向
我试图弄清楚如何为放置在 Microsoft-IIS/7.0 类型服务器上的网站设置 301 永久重定向。 假设我有域名 www.A.com 并且我想将其重定向到 www.B.com 我可以在我的 web.config 文件中使用类似以下内容:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to WWW" stopProcessing="true">
<match url="A.com" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.B.com$" />
</conditions>
<action type="Redirect" url="http://www.B.com/{R:0}"
redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
将 web.config 放在根目录中时,服务器回复:
403 - 禁止:访问被拒绝。 您无权使用您提供的凭据查看此目录或页面。
有什么建议为什么会出现这个 403 错误吗?
提前致谢。
Im trying to figure out how to setup a 301 permanent redirect for a website that is placed on a Microsoft-IIS/7.0 type server.
So let's say I have domain www.A.com and I want to redirect this to www.B.com I could use something like the following in my web.config file:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to WWW" stopProcessing="true">
<match url="A.com" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.B.com$" />
</conditions>
<action type="Redirect" url="http://www.B.com/{R:0}"
redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
When placing the web.config in the root directory, the server responds:
403 - Forbidden: Access is denied.
You do not have permission to view this directory or page using the credentials that you supplied.
Any suggestion why this 403 error is given?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您在普通(默认)web.config 和完全普通的 Default.aspx 中遇到 403 错误,则 IIS 存在配置问题。应用程序池很可能没有网站基本文件夹的权限。听起来您处于托管状态,因此请联系系统管理员。
If you are getting a 403 error with a plain (default) web.config and totally vanilla Default.aspx, then there is a configuration problem with IIS. Most likely the app pool does not have rights to the base folder for the website. Sounds like you're in a hosted situation so contact the system administrator.
这应该可行并且也更简单。您不需要 URL 重写,只需 HTTP 重定向。
至于 403,IIS 应用程序池是否具有对站点根目录文件夹的读取权限?
This should work and also be much simpler. You don't need URL rewriting, just HTTP redirect.
As for the 403, does the IIS application pool have read access to the folder at the root of your site?