The following directory structure will be the basis of my question:
_css (this is a folder)
public (this is a folder)
Both _css and public folders are sibling folders.
Here's how my .htaccess file looks like:
RewriteRule ^login/*$ public/login.php [L]
RewriteRule ^login/([^/.]_)/?$ public/login.php?a=$1 [L]
Let's say my domain name is www.mySite.com.
When I use the URL http://www.mySite.com, the DirectoryIndex knows to redirect to 'public/login.php'. To make the styles in my style sheet take effect, I have to define my style sheet within 'login.php' as:
<link rel="stylesheet" [b]href="_css/main.css"[/b] />
But notice, the path point of reference is the application root and not the 'public' folder; otherwise, I would've had to define the path to my style sheet as ../_css/main.css instead of _css/main.css.
Now let's say I use this URL: http://www.mySite.com/login/a=logout, the bottom RewriteRule would kick in and redirect me to public/login?a=logout. But I noticed all the style settings in login.php would be gone! Somehow, to make it look normal, I'd have to redefine the path to my style sheet as '../_css/main.css' instead of the original '_css/main.css'. What this tells me is that Apache now thinks its path point of reference is in the public folder instead of the application root as it did before, causing it to be unable to find my 'main.css'.
This is kind of driving me crazy because I don't know how mod_rewrite determines its path point of reference. In one situation, it's the application root directory, then in another situation, it's using the 'public' subdirectory of the application root. To the more experienced people on mod_rewrite, I would appreciate some sage advise on how you overcome this behavior.