繁体   English   中英

ASP.NET IIS7的永久301重定向

[英]Permanent 301 redirect for ASP.NET IIS7

我试图弄清楚如何为放置在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错误?

提前致谢。

如果使用普通(默认)web.config和完全香草的Default.aspx收到403错误,则IIS存在配置问题。 应用程序池很可能无权访问网站的基本文件夹。 听起来您处于托管状态,请与系统管理员联系。

这应该有效并且也更简单。 您不需要URL重写,只需HTTP重定向。

至于403,IIS应用程序池是否对站点根目录的文件夹具有读取权限?

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpRedirect enabled="true" destination="www.B.com" httpResponseStatus="Permanent" />
    </system.webServer>
</configuration>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM