5

Ok so I have a weird problem. I have a local XAMPP running and running Acrylic DNS Proxy as well. While I was testing some code I noticed that it was running the script twice. Here's what I got.

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

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>

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"

But if you go to www.test.com, the text.txt output is "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
3
  • try this, and .. $ curl test.com/index.php Commented Nov 4, 2013 at 3:28
  • I believe test.com is calling twice which is the default behavior to run index.php. Kindly check your access_log if test.com is accessing twice. There could be redirect problem happening here Commented Nov 4, 2013 at 3:49
  • My Access log says "GET / HTTP/1.1" 200 466 "GET /favicon.ico HTTP/1.1" 404 1067 "GET / HTTP/1.1" 200 466 Do you think it could be because of the 404? Commented Nov 4, 2013 at 4:02

1 Answer 1

7

It looks like it was because chrome was looking for favicon.ico (which caused a 404) and my .htaccess file points all 404s to index.php file which executed the code again.

Sign up to request clarification or add additional context in comments.

2 Comments

Please mark this as an answer. This may help someone facing the same problem.
Wait, where is that .htaccess, i have the same problem and mayne this is the answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.