apache - How do I stop my index.php being run twice for every user -
we've got webapp initial html served using apache , php.
i noticed index.php being run twice every request. seems caused / effected 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 moving parameter url path query string. i.e.
http://ourdomain.com/hotels/vegas?someparam=1
becomes
http://ourdomain.com?d=vegas&someparam=1
if go directly query string version index.php run once. if use url redirected, index.php run twice (i'm checking adding error_log('end of index.php')
file).
so example going http://ourdomain.com/hotels/paris
hits file twice http://ourdomain.com?d=paris
hits once.
i've seen this question , had @ blog mentioned, , can't find empty string url's (i've tried using yslow process).
can tell me why happening? or how fix it?
edit
it looks it's javascript error i'm getting http requests "get /hotels/undefined http/1.1"
in access log.
try last rule as:
rewriterule ^hotels/([^/]+)/?$ index.php?d=$1 [nc,qsa,l]
or catch erroneous requests
rewriterule ^hotels/((?!undefined)[^/]+)/?$ index.php?d=$1 [nc,qsa,l]
Comments
Post a Comment