Hi. I'm new to this forum, this is my first post. This is my "scenario": I have a site on: /var/www/html/mysite this site is reachable by: mysite.mydomain.com (docroot: /var/www/html/mysite) or localhost/mysite (docroot: /var/www/html) if i set RewriteBase / it works for mysite.mydomain.com if i set RewriteBase /mysite/ it works for localhost/mysite Is there way to set RewriteBase automatically to the directory .htaccess is in? Or some other way to make the rules work for any possible "request"?
For anyone who had the same problem, this is ONE possible solution: # BASE RewriteBase / # Store the current location in an environment variable CWD RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$ RewriteRule ^.*$ - [E=CWD:%2] # Just by prefixing the environment variable, we can safely rewrite anything now RewriteCond %{REQUEST_FILENAME} !-f ^(.*)$ %{ENV:CWD}index.php?var=$1 [L] Hope this could be helpful..