Q:

.htaccess mod_rewrite country code prefix

Lets say I have a site called example.com that has the following pages:
example.com
example.com/foo
example.com/bar

Now I want to create an Australian version of the site. The content for most pages will be the same on both sites but the URL structure will be:
example.com/au
example.com/au/foo
example.com/au/bar

All requests are already routed through index.php by the following in my .htaccess file:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]

How can I alter this so both example.com/foo and example.com/au/foo are both routed though index.php. As far as index.php is concerned I want it to treat both pages in the same way.
The logic to determine which content to show will happen later and is out of the scope of this question.

A:

One Small Tweak
I'm assuming that neither foo nor bar are actual directories.

RewriteCond %{REQUEST_FILENAME} !-f checks that the request is not an existing file
RewriteCond %{REQUEST_FILENAME} !-d checks that the request is not an existing directory

Both example.com/foo and example.com/au/foo meet these conditions, and will therefore follow the rule. Let's make one small tweak so that index.php does not get polluted by path fragments:
RewriteRule ^ index.php [L,DPI]

With that, you should be set. :)

