In this particular case there's no query string because Apache does not recognize '?', there's only a %3F. So (.*) gets what is after file.php and send it as a query string (qs) It is working fine now as a partial solution.
WRONG! Apache knows that %3F is the ? character and will treat everything after it as a query string. Because the query string is NOT available to the regex in a RewriteRule (only available in a RewriteCond statement and only when specified), your (.*) will NEVER match anything (unless you've enabled MultiViews which, IMHO, is a dumb thing to do). Test it and look at the value (null every time) that $1 returns.
Actually I already have '...com$1' but it has be '...com/$1' if the rule is placed in .htaccess instead of httpd.conf
I substituted those both httpd.conf lines by your Code Generator (nice!)
RewriteCond %{HTTP_HOST} !www\. [NC]
RewriteRule .? http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Another (not all) directives in httpd.conf
ServerAlias www.domain.com ...
# Handle TRACE request
RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .? - [F]
# retain query string
RewriteCond %{QUERY_STARING} !'' # string not empty
RewriteRule .? %{REQUEST_URI}? [QSA,L]
# that accomplishes exactly nothing!
<Directory /path/to/www>
Options Indexes IncludesNOEXEC FollowSymLinks +ExecCGI
allow from all
AllowOverride All
...
</Directory>
...
There are also some directives in .htaccess (waiting moving) like IndexIgnore, Limit GET POST, Limit PUT DELETE, Enable GZIP, Expire headers, cache headers and rewrite rules from old to new site and shorcuts.
Also both domain.com and www.domain.com have 'A' records to the same IP
Problem persists

Thank you!
Bookmarks