网站被调用两次?

问题描述:

我的问题是,我的PHP网站被称为两次。 但我不知道为什么。在我的访问日志我也得到两个条目,如果我重装:网站被调用两次?

127.0.0.12 - - [13/Oct/2010:20:41:56 +0200] "POST /index.php HTTP/1.1" 200 1493 "http://mkw-testing/index.php" "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.36 Safari/534.7" 
127.0.0.12 - - [13/Oct/2010:20:41:57 +0200] "GET /favicon.ico HTTP/1.1" 200 1498 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.36 Safari/534.7" 

我error.log中显示:

[Wed Oct 13 21:08:35 2010] [debug] mod_deflate.c(615): [client 127.0.0.12] Zlib: Compressed 2766 to 1067 : URL /index.php 
[Wed Oct 13 21:08:35 2010] [debug] mod_deflate.c(615): [client 127.0.0.12] Zlib: Compressed 2743 to 1038 : URL /index.php/favicon.ico 

我可以做什么?我没有任何重定向,重新加载aso。在JavaScript代码中。

thx4help

可能是否存在Cookie问题?

shell我使用htaccess文件得到的网站只被称为一次?

UPDATE

影响无关的存取权限的日志是我的网站明明叫了两声!事实是,如果我打印出一个索引,每增加一个呼叫点,显示的网站只显示奇数。所以它只有一个而不是一个。增量函数在代码中不会被调用两次。如果我打印索引到一个文本文件,我得到每一个数字,不仅是奇数。 ....我不知道该怎么做:-S,到哪里去寻找,如何调试....

这里我的html:

<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
     <link rel="icon" href="favicon.ico" type="image/x-icon"> 
     <title>Testsuite</title> 

     <style type="text/css"> 
      ... 

     </style> 

    </head> 
    <body> 
<!--script type="text/javascript">alert("go home!");</script--> 
<p style="font-size: smaller; color: #555"> 
Testcases ID: 75<br> 
Verbleibend: 94.5 % noch zu checken...<br> 
</p> 

<div id="action"> 
<h2>Suchprofile</h2> 
<p> 
    Screen number: B01 (4)<br> 
    Pfad: /search/type<br><br> 
</p> 
</div> 

<h2></h2> 

<form name="testsuite" action="/index.php" method="POST"> 
    <p style="width: 650px;"> 
     <span style="color: gray">Ausgangassituation:</span> Der User befindet sich auf der /search/type Seite. <br> 
     <span style="color: gray">Eingabe:</span> Der User klickt auf ?Dieses Suchprofil speichern?.   <br><br> 
     Reaktionen 
     <input type="hidden" name="id_testcase" value="75" /> 
    </p> 
    <table width="650" border="1" cellspacing="0" cellpadding="0" > 
      <tr> 
      <td>Es &ouml;ffnet sich ein Eingabefeld </td> 
      <td class="checkbox"><input type="checkbox" name="requirements[]" value="103" /></td> 
     </tr> 
      <tr> 
      <td>Rechts neben dem Eingabefeld wird ein Plus-Symbol angezeigt.</td> 
      <td class="checkbox"><input type="checkbox" name="requirements[]" value="104" /></td> 
     </tr> 
     </table> 

    <br> 
    <div style="border: 1px dashed #ccc; width: 650px; background-color: #ddd"> 
    <input type="radio" name="action" value="skip" id="skip" /><label for="skip">Ignorieren</label><br> 
    <input type="radio" name="action" value="store" id="store" checked/><label for="store">Speichern</label><br> 
    <br> 
    <center> 
     <input type="submit" id="submitter" value="weiter" /> 
    </center> 
    </div> 
</form> 




    </body> 
</html> 
+0

WTF ??这种现象只发生在铬中。 – helle 2010-10-13 19:52:57

+0

检查您是否使用adblock插件。我有同样的问题,当我停止插件问题解决。 – resul 2012-01-09 19:06:30

这是Chrome的一个已知怪癖。它重新请求每个页面调用favicon.ico(甚至查看源!)其他浏览器缓存它。没有什么需要关注的。只要确保该文件存在以避免404开销! - 通过@chigley

UPDATE

思考404问题后,我发现了另一项决议。

加入这一行到您的.htaccess文件:

RewriteCond %{REQUEST_URI} !^/favicon\.ico [NC] 

过时且不适用

HM能够接受这个线程的答案......我发现了一个相当容易方式不对此要求作出反应... 但它仅适用于testreason

我只是把这个在我的索引文件的第一行PHP:

if($_SERVER['REQUEST_URI'] == "/favicon.ico") return false; 

即使favicon.ico的是有这将帮助你避免在错误日志文件的重复输入。它使得它更具可读性。


你要知道,我使用的是.htaccess文件是这样的:

Options +FollowSymLinks 
IndexIgnore */* 
# Turn on the RewriteEngine 
RewriteEngine On 
RewriteBase/
# Rules 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !^/favicon\.ico [NC] 
RewriteRule . index.php 
+0

等待404错误,愚蠢 – 2011-01-26 09:56:12

+0

@col。弹片...更好的这种方式^^? – helle 2011-01-26 10:13:21

您的网站确实是叫了两次,但您的索引页只被调用一次。其他请求寻找favicon.ico,即浏览器会在标签/窗口的页面驻留显示

编辑图标:下面 @ TokenMacGuy的评论可能是正确的金钱。

+0

好吧,但我打印出一个变量,每次调用索引,并获得两个条目,每次调用......? :-S – helle 2010-10-13 18:55:03

+0

您能提供打印出该变量的代码吗? – 2010-10-13 18:58:15

+1

@helle - 这是Chrome已知的怪癖之一。它重新请求每个页面调用favicon.ico(甚至查看源!)其他浏览器缓存它。没有什么需要关注的。只要确保该文件存在以避免404开销! – chigley 2010-10-13 18:59:47

第二个调用是浏览器尝试获取收藏夹图标(favicon.ico)。显然你有一个,因为你的服务器返回状态200,所以没有问题。

+1

它返回状态200,因为网络服务器解释GET /favicon.ico以index.php/favicon.ico的路径调用index.php。这很烦人!应该可能有一个真正的favicon.ico文件来解决它。 – SingleNegationElimination 2010-10-13 19:27:11

+0

可能是一个mod_rewrite破解重定向一切非物理(文件/目录)通过index.php – 2010-10-13 19:54:13

+0

favicon是有...嗯。这是一个实习工具,所以这个问题已经没有优先权了。我们现在使用firefox而不是chrome ... – helle 2010-10-14 14:17:39

这是完全正常的,因为第二秒呼叫是为了检索favicon,这是一个通常出现在浏览器标签上的小图标。即使你没有它,浏览器通常也会尝试获取它。

的原因,为什么我的index.php加载,两次是另一个(这样不是图标):在我.htaccess我有我的

ErrorDocument 404 

命令在文件的末尾。把它

RewriteEngine On 

的伎俩。


赫勒的回答使我到另一个有帮助(很简单)的想法:找出来,其请求被呼唤你的index.php,干脆把以下在它的开头:

file_put_contents('stats/stats.txt', $_SERVER['REQUEST_URI'], FILE_APPEND);