In my bootstrap.php
I have the following:
if($_SERVER['SERVER_NAME'] == 'localhost')
Kohana::$environment = 'development';
else
Kohana::$environment = 'production';
...
switch(Kohana::$environment)
{
case 'development':
$settings = array('base_url' => '/kohana/', 'index_file' => FALSE);
break;
default:
$settings = array('base_url' => '/', 'index_file' => FALSE);
break;
}
In .htaccess
have this:
# Installation directory
RewriteBase /kohana/
This means that if I just upload my kohana application, it will break because the RewriteBase in the .htaccess
file will be wrong. Is there a way I can have a conditional in the .htaccess
file similar to the one I have in the bootstrap so that it will use the correct RewriteBase?
If your htaccess file is in the installation base (ie next to index.php), then you don't particularly need RewriteBase, i leave it out of my applications and they work beautifully. Even with two Kohana installs, one inside the other directory.
I don't think there is a way to have a conditional
RewriteBase
. The only way in Apache that comes to mind is putting theRewriteBase
directive into a<Location>
tag but that is only available in httpd.conf itself, not in .htaccess files.What I usually do in such cases is define a different AccessFileName in the local environment, for example
htaccess.txt
. That file will contain the local rewrite rules, while.htaccess
contains the server side ones.I ran across this while looking for a similar solution. While I didn't get RewriteBase to set conditionally, I did get a similar effect by setting an environment variable and using that in the following rules. Here's an example of what I mean.