Background
I have php/js software (Piwik), which sets a cookie to track visits to the site.
Our site (ie; not Piwik) is setup so that all URLs (except for resources) are written back to /public/index.php.
This way, our users each get a unique URL, such as;
... etc
For me to track each of these user URLs in Piwik, it has been suggested that I need to set the path in the cookie to one that Apache maps to an actual directory.
Since we don't have actual directories for each of our users, we cannot do this.
Finally, we move on to using RewriteBase within the .htaccess to tell Apache that we consider the user's URL to be its own directory.
This falls short, however, as there does not appear to be a way to use RewriteBase without hardcoding the 'base'.
The question
Can I do something like this in my .htaccess? Francois Deschenes's answer says I cannot do this.
RewriteCond ^([^/]*)(/.*)?
RewriteBase %1
What other alternatives do I have for ensuring the 'path' of the cookie is set to be the user's URL rather than just '/'?
What I have currently
The .htaccess in / contains;
RewriteRule ^(.*)$ /public/$1 [L]
Then the .htaccess in /public contains;
RewriteRule ^index\.php5/(.*)$ - [L]
RewriteRule ^index\.php5?(.*)$ - [L]
RewriteRule ^index\.php5$ - [L]
RewriteRule ^(.*)$ /public/index.php5 [L]
Note that both of these have other rules at the beginning for paths that have moved, etc.
Thanks for any and all help!
What I have tried
Calling .setCookiePath() on the JS Piwik object, as suggested in the Piwik documentation. For example, for the URL http://www.example.com/user1 , calling .setCookiePath('/user1') does not infact set the cookie's path.
Adding a trailing slash to the URL, then calling .setCookiePath(). For example, the URL http://www.example.com/user1/ then calling .setCookiePath('/user1') does not set the cookie's path.
Related questions
With mod_rewrite can I specify a RewriteBase within a RewriteCond? - Unfortunately the answer doesn't indicate if I can use the current path as the base.