[英]PHP Script Running Twice
Ok so I have a weird problem. 好的,我有一个奇怪的问题。 I have a local XAMPP running and running Acrylic DNS Proxy as well.
我有一个本地XAMPP运行并运行丙烯酸DNS代理。 While I was testing some code I noticed that it was running the script twice.
当我测试一些代码时,我注意到它运行了两次脚本。 Here's what I got.
这就是我得到的。
index.php 的index.php
<?php
$myFile = "test.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
$stringData = "1\n";
fwrite($fh, $stringData);
fclose($fh);
?>
.htaccess 的.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
AcrylicHosts.txt AcrylicHosts.txt
127.0.0.1 test.com
127.0.0.1 *.test.com
Vhost File 虚拟文件
<VirtualHost *:80>
DocumentRoot /www/test
ServerName test.com
ServerAlias *.test.com
</VirtualHost>
<VirtualHost *:443>
DocumentRoot /www/test
ServerName test.com
ServerAlias *.test.com
SSLEngine On
SSLOptions +StrictRequire
SSLEngine on
SSLCertificateFile conf/ssl.crt/server.crt
SSLCertificateKeyFile conf/ssl.key/server.key
SSLProtocol TLSv1
</VirtualHost>
If you go to test.com , the text.txt output is " 1\\n 1\\n " 如果你去test.com ,text.txt输出是“ 1 \\ n 1 \\ n ”
But if you go to www.test.com , the text.txt output is " 1\\n " 但如果你去www.test.com ,text.txt输出是“ 1 \\ n ”
Anyone know what to do to get it to stop running twice? 任何人都知道如何让它停止运行两次?
Edit: 编辑:
These are the versions I'm working with: 这些是我正在使用的版本:
Apache 2.4.4
MySQL 5.5.32
PHP 5.4.19
它看起来是因为chrome正在寻找favicon.ico(导致404)而我的.htaccess文件将所有404指向index.php文件,该文件再次执行代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.