This one baffles me, and if its not script specific then its something wrong with the Amazon AMI hosting my application.
I’m posting the exact contents of my .htaccess and index file. The only difference is the email I’m sending to.
this is my .htaccess file
<IfModule mod_rewrite.c>
Options +FollowSymlinks
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteBase /
</IfModule>
Options -MultiViews
<IfModule mod_autoindex.c>
Options -Indexes
</IfModule>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
and this is my index.php
<?php
mail('me@email.com', '', '7');
when i load my index page i will get 2 e-mails with my current set up. But if I comment out the RewriteRule and load the index page, I correctly get 1 email sent to me.
Has anyone encountered this?
Edit:
access_log shows this with RewriteRule
[21/Feb/2013:03:48:27 +0000] "GET / HTTP/1.1" 200 - "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17"
[21/Feb/2013:03:48:27 +0000] "GET /favicon.ico HTTP/1.1" 200 - "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17"
access_log shows this without RewriteRule
[21/Feb/2013:03:47:58 +0000] "GET / HTTP/1.1" 200 - "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17"
[21/Feb/2013:03:47:58 +0000] "GET /favicon.ico HTTP/1.1" 404 295 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17"
The problem is that you’re routing every single request for a non-existent file to
index.php. Browsers will automatically make a request to http://yourdomain.com/favicon.ico when a page is loaded. Since this file doesn’t exist yet on your site,index.phpis getting hit again. You can avoid this by checking$_SERVER['SCRIPT_FILENAME']inindex.phpand only generating mail if it’s supposed to be a page (in contrast to an image file, etc).For example:
That checks for
ico,jpg,png,gifandtxtfiles.