Saturday, 10 August 2013

Select environment in Laravel 4 using .htaccess

Select environment in Laravel 4 using .htaccess

I have a site that is in the testing phase, so it connects not to the real
data but to a local copy of a database.
My customer needs now a fast link to retrieve some urgent and important
pdf reports, so I need to set up another version of the site that links to
the "real data".
I can create two environments ("local" and "real") with different database
connections, and I would like to give the opportunity to select the
environment via the URL (I know it's not pretty from a security point of
view, but let's take this for granted).
So I would like to use:
my.ip.address/mysite to use the test db
my.ip.address/mysite/real to usew the real db, redirecting to the URLs
without the "real folders".
F.ex.: /mysite/real/admin shoud redirect to /mysite/admin but selecting
the "real" environment on Laravel 4.
1) is it possible to pattern-match also folders in Laravel 4 or is it
possible only for domains? In other words, does this work?
$env = $app->detectEnvironment(array(
'test' => array('*/mysite/*'),
'real' => array('*/mysite/real/*'),
));
2) if so, I just can't figure out how to write the .htaccess rule, I've tried
RewriteRule ^/real(.*)$ $1
but it won't work.

No comments:

Post a Comment