【问题标题】:url redirect error to www or httpsurl 重定向错误到 www 或 https
【发布时间】:2016-01-07 02:25:34
【问题描述】:

有时我的网站会将访问者重定向到我的错误页面“is_error.aspx” 当一些人打开主页或任何其他页面时,我的网站是 ASP.NET,我使用的是 windows server 2012

web.config 包含以下行:

         <customErrors mode="On" defaultRedirect="/is_error.html">
              <error statusCode="404" redirect="/is_error.html" />
         </customErrors>
    </system.web>
    <system.webServer>
     <defaultDocument>
      <files>
        <add value="index.aspx" />
      </files>
     </defaultDocument>
     <httpErrors errorMode="DetailedLocalOnly">
      <remove statusCode="500" subStatusCode="-1" />
      <remove statusCode="403" subStatusCode="-1" />
      <remove statusCode="401" subStatusCode="-1" />
      <remove statusCode="404" subStatusCode="-1" />
      <error statusCode="404" prefixLanguageFilePath=""       path="/is_error.html" responseMode="ExecuteURL" />
      <error statusCode="401" prefixLanguageFilePath="" path="/is_error.html" responseMode="ExecuteURL" />
      <error statusCode="403" prefixLanguageFilePath="" path="/is_error.html" responseMode="ExecuteURL" />
      <error statusCode="500" prefixLanguageFilePath="" path="/is_error.html" responseMode="ExecuteURL" />
    </httpErrors>
   <rewrite>
            <rules>
                <rule name="CanonicalHostNameRule1">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^www\.feee3\.com$" negate="true" />
                    </conditions>
                    <action type="Redirect" url="http://www.feee3.com/{R:1}" />
                </rule>
                <rule name="feee3Https" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTPS}" pattern="^OFF$" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
                </rule>
            </rules>
        </rewrite>      
    </system.webServer>

“is_error.html”页面:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>feee3.com</title>
<script type="text/javascript">
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
</script>
</head>
<body onload="MM_goToURL('parent','is_error.aspx');return document.MM_returnValue">
</body>
</html>

我不知道将我的域重定向到“www”的问题 或将其重定向到“https”! 或者我可以用另一种方式在 web.config 中编写“重写”部分吗?所以在一行中它重定向到“www”和“https”?

【问题讨论】:

    标签: url redirect web https web-config


    【解决方案1】:

    找了好久才发现问题,只好把web.config里面的几行换了:

    <customErrors mode="On" defaultRedirect="/is_error.html">
              <error statusCode="404" redirect="/is_error.html" />
    </customErrors>
    

    用这条线:

    <customErrors mode="Off"/>
    

    我用谷歌搜索了我的网站,然后点击链接,我的网站就打开了 没有错误,然后我按退格键返回上一页(我的谷歌搜索我的网站)并再次单击我的链接,我重复了大约 50 次 最后出现错误,找不到图像路径 错误来自我的数据库,数据库中存储了图像路径但网站文件夹中不存在图像,所以我只是删除了数据库记录,一切正常。

    【讨论】:

      猜你喜欢
      • 2016-10-14
      • 2018-03-31
      • 2018-07-14
      • 2018-07-25
      • 1970-01-01
      • 2020-05-22
      • 2012-06-09
      • 1970-01-01
      相关资源
      最近更新 更多