Welcome Guest, Not a member yet? Register   Sign In
multiple applications, mod_rewrite and .htaccess
#1

[eluser]Tom Vogt[/eluser]
After searching through the forums, experimenting and generally wasting at least an hour more than should be necessary, I've finally come up with a clean way to run multiple applications.

Directory structure:
- system
-- application
--- someapp
--- anotherapp
--- thirdapp


my .htaccess (in the top dir):
Code:
RewriteEngine on

RewriteCond $2 !^(index(|_[^\./]+)\.php|robots\.txt)
RewriteRule ^(someapp|anotherapp|thirdapp)(.*)$ /index_$1.php/$2 [L]

RewriteCond $1 !^(index(|_[^\./]+)\.php|images|common|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]


and then make new index.php files with filenames of "index_someapp.php", "index_anotherapp.php", etc. and the only difference among them is the setting of $application_folder (which should point to "application/someapp" etc.



Possible Improvements:
You could probably replace the list with a wildcard, but that should be a bit carefully constructed to prevent security problems, so I simply put the list in there, it's not as if I'd be changing the deployed apps all the time.

Just copying the index.php isn't necessarily the best solution, since only one line of 133 changes, so a bit of require_once() would greatly improve that part.



Other comments?
#2

[eluser]John_Betong[/eluser]
 

Check out:

Development test/sandbox site




Theme © iAndrew 2016 - Forum software by © MyBB