同步RewriteBase和HTML基本标记

For a small PHP web application I want to start right away with beautiful links. Therefore I put an .htaccess with mod_rewrite in the base directory of my app to redirect up to three levels of "directories" to an index.php-file, giving the directories as a parameter.

RewriteEngine on

RewriteBase /appdirectory

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^([^/]*)(/([^/]*)(/([^/]*))?)?$ ./index.php?id1=$1&id2=$3&id3=$5

This works perfectly, the only pitfall I noticed is that ressources reffered to in the PHP/HTML files by relative paths are not found anymore. This was no big surprise, since the browser is parsing the HTML and the browser only knows the beautified URL the user submitted to the server. I was able to solve this problem using the HTML base tag. I think of relative links as a quite elegant solution and definitely want to stick with them.

To make the app installable in a subdirectory of a webserver, I also had to add a RewriteBase to my .htaccess file. Obviously, the RewriteBase and the HTML base are allways the same for my app.

The problem in usability I see is, that the user who wants to install the application needs to set both the RewriteBase and the HTML base to the subdirectory on his or her server.

Is there a way to somehow sync both properties? Do you know any other solution which is more user-friendly? Is there a way to solve this problem by using a PHP variable containing the install subdirectory or even let it be autodetected somehow for both mod_rewrite and HTML?