简体   繁体   English

页面无法正确重定向-PHP和IIS重定向循环

[英]The page isn't redirecting properly - PHP and IIS redirect loop

I have a PHP site that is hosted in Windows (IIS) . 我有一个Windows(IIS)托管的PHP站点。 The domain is held at Network Solutions, but the site is hosted at GoDaddy , so I have a DNS entry at Network Solutions that resolves both the " www " and " non-www " names to the GoDaddy server where my code is. 该域位于Network Solutions,但该站点托管在GoDaddy ,因此我在Network Solutions上有一个DNS条目,该条目将“ www ”和“ 非www ”名称都解析为我的代码所在的GoDaddy服务器。

When I put a redirect rule in my IIS web.config file to redirect requests from various pages, I get what appears to be a redirect loop. 当我在我的IIS web.config文件中放置一个重定向规则以重定向来自各个页面的请求时,出现了一个重定向循环。
Firefox says: Firefox说:

The page isn't redirecting properly 页面未正确重定向

IE just says: IE只是说:

The page cannot be displayed 该页无法显示

Chrome says: Chrome说:

This page has a redirect loop 该页面具有重定向循环

So I went to Fiddler , which verified a bunch of requests, with each saying the server is reporting " Object Moved. This document may be found here " (with "here" being a hyperlink to the page that should be getting redirected to), only it happens over and over and over (the loop). 因此,我去了Fiddler ,它验证了一堆请求,每个请求都说服务器报告“ Object Moved. This document may be found here ”(“ here”是指向应重定向到的页面的超链接),只有它一遍又一遍地发生(循环)。

Could this be due to the site being hosted elsewhere than where the domain is? 这可能是由于该站点托管在域所在的其他位置吗? I'm stuck. 我被卡住了。

Here's my web.config file (actual URL replaced with "example"): 这是我的web.config文件(实际URL替换为“ example”):

<rewrite>
   <rules>
      <rule name="Redirect to forums" stopProcessing="true">
         <match url=".*" />
         <conditions>
            <add input="(.*\.mysite.com)/([_0-9a-z-]+)" />
         </conditions>
         <action type="Redirect" url="http://www.example.com/forums.php" />
      </rule>
   </rules>
</rewrite>

Someone suggested removing the " http:// " from the action above, which I tried, but I still get the error. 有人建议从上面的操作中删除“ http:// ”,但我仍然遇到错误。

Any help would be very appreciated. 任何帮助将不胜感激。 Thanks. 谢谢。

Just noticed a stupid error: In the block, 刚注意到一个愚蠢的错误:在代码块中,

<add input="(.*\.mysite.com)/([_0-9a-z-]+)" />

The area to search should have been specified, as well as the pattern to match against in a separate argument. 应该已经指定了要搜索的区域,并在单独的参数中指定了要匹配的模式。 There was no "pattern=" statement! 没有“ pattern =”语句! It should have been like so: 应该是这样的:

<add input="{HTTP_HOST}" pattern="(.*\.mysite.com)/([_0-9a-z-]+)" />

DOH! DOH! I'm tired. 我累了。

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

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