We've got a webapp where the initial html is served up using apache and php.
I recently noticed that index.php was being run twice for every request. This seems to be caused / effected by the rewrite rules in our .htaccess -
RewriteCond %{HTTP_HOST} ^(www\.|hotels\.)ourdomain\.com$ [NC,OR]
RewriteCond %{SERVER_NAME} ^(www\.|hotels\.)ourdomain\.com$ [NC]
RewriteRule (.*) http://ourdomain.com/$1 [R=301]
RewriteRule ^hotels/([^/]+)/?\??(.*)$ ?d=$1&$2 [QSA]
The final rule is moving a parameter from the url path to the query string. i.e.
http://ourdomain.com/hotels/vegas?someParam=1
becomes
http://ourdomain.com?d=vegas&someParam=1
If I go directly to the query string version then index.php is only run once. However if use a url that will be redirected, then index.php is run twice (I'm checking by adding error_log('end of index.php')
to the file).
So for example going to http://ourdomain.com/hotels/paris
hits the file twice where as http://ourdomain.com?d=paris
only hits it once.
I've seen this question and had a look at the blog mentioned, and I can't find any empty string url's (I've tried using yslow for this process).
Can anybody tell me why this is happening? or how I fix it?
EDIT
It looks like it's a javascript error I'm getting http requests like "GET /hotels/undefined HTTP/1.1"
in the access log.