I'm making a downloadable self-hosted web app (using CodeIgniter), and need the .htaccess rewrite rule to be able to tell if it's in a subdirectory or not to be able to make the rewrite rule correctly.
For example, if the app is being installed at example.com, then the write rule will look like
RewriteRule ^(.*)$ /index.php/$1 [L]
If, on the other hand, it's installed at example.com/subdir, then it'll look like
RewriteRule ^(.*)$ /subdir/index.php/$1 [L]
How can I make this happen? Is there a way to combine those into one "smart" rule? Or do I need to create the .htaccess programmatically during the app's installation rather than just bundle it with the download?