R
R
Ruslan Khoroshkevich2013-11-09 15:16:03
PHP
Ruslan Khoroshkevich, 2013-11-09 15:16:03

Weird glitch in Chrome

Hello. Help solve the problem. There are two sites configured according to my article - test.dev and test0.dev. At the root of the sites are the same .htaccess :

AddDefaultCharSet utf8
php_flag display_errors on
php_flag display_startup_errors on
ErrorDocument 401 /error/401.html
ErrorDocument 403 /error/403.html
ErrorDocument 404 /error/404.php
Options -Indexes
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?route=$1 [L]

And the same index.php :
<?php
session_start();
if(!isset($_SESSION['count'])) {
  $_SESSION['count'] = 0;
        $_SESSION['count1'] = '0';
}
++$_SESSION['count'];
$_SESSION['count1'] = $_SESSION['count1'] . '/' . $_SESSION['count'];
echo $_SESSION['count'] . "<br>";
echo $_SESSION['count1'] . "<br>";
exit;

In firefox and IE, everything works fine, but in browsers on webkit (chrome and opera), the counter increases by 2. Moreover, in test.dev it is considered as expected (1, 2, 3, 4, 5 ...), and in test0.dev it jumps by 2 (1, 3, 5, 7, 9 ...). It's like pressing F5 twice in chrome .
Experimentally found out that commenting on this line
RewriteRule ^(.*)$ index.php?route=$1 [L]
leads to a normal countdown. And this behavior is only on one site.
Does anyone have any ideas why this is happening?

The trick is that on one site this code works, on the second it does not work correctly. And only in case of webkit. To be honest, I already have a brain explosion. I run both sites on the same machine, in the same browser (in different tabs). I thought maybe RewriteRule was written incorrectly.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
F
FanatPHP, 2013-11-09
@Zezst

Well, why is this happening - it’s just not surprising if the entry point is configured as a 404 handler.
And why on the second ... Well, apparently, they didn’t forget to put a favicon there.
Hint: "Network" tab should open on "double requests" first.

N
Nikita Gusakov, 2013-11-09
@hell0w0rd

Chrome, regardless of the presence of information about the favicon in the body of the page, tries to request it. In general, so that such questions arise less often - immediately turn on logging, everything will be clear to you immediately

N
noonesshadow, 2013-11-09
@noonesshadow

HEAD request probably
need to monitor the network and watch

A
Andrey, 2013-11-09
@reaferon

I had a very similar, for a long time I could not understand what the reason was.
I found out: in Chrome, some kind of SEO extension (I don’t remember the name) independently pulled each requested page. Well, the counter, respectively, also doubled.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question