GGshow reloaded GGshow reloaded

January 15, 2012

Double/Multiple execute of bootstrap

Issue:

  • bootstrap is being executed twice.
  • specified action is being called twice.
  • counter increased twice per hit.

Reason:

  • Web browser loads a file which is not exist, either through src or href attribute with invalid or empty value (e.g. favicon.ico, global.css, & etc.), web server treats it as “Page not found” error (404).
  • Default configuration for Zend application, the default application (index.php) will handle error 404, an error message “Invalid controller specified” will be displayed, indirectly causing code in bootstrap.php also being executed.

Solution:

  • Create a favicon.ico in DocumentRoot. and
  • Prevent loading any file which is not exist. or
  • Modify web server configuration (httpd.conf or .htaccess),
    rewrite rule to exclude paths for specified file type.

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} (.*).(woff|ttf|svg|js|ico|gif|jpg|png|css|htc|xml|txt|swf)$
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
Filed under: PHP,Web,Zend Framework — Tags: , , — GG @ 1:43 am

No Comments »

No comments yet.

RSS feed for comments on this post.

Leave a comment

© 2017 GGSHOW | Powered by WordPress