lucy24 - 12:43 am on Feb 2, 2012 (gmt 0)
Should I re-write the script to create the URL to the direct folder each time?
Generic answer: any links within your site must point to the "correct" URL-- that is, the one you want users and search engines to see. So if links are generated by a php script, make sure the script generates links in their displayed form, not their behind-the-scenes form.
RewriteRule ^(([^/]+/)*)index\.php(([^/]+/)*)$ http://www.example.com/$1$2 [R=301,L]
The RewriteRule itself doesn't "see" the host or the query. So the second capture would always be empty. If $2 is meant for the query string, it can only come from THE_REQUEST or from QUERY_STRING. So it would be %2 (or %1 or whatever number it comes out to be) for material captured in a Condition.