在我的 bootstrap.php中我有以下几点:
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; }在的.htaccess 有这样的:
# Installation directory RewriteBase /kohana/这意味着,如果我刚刚上传我的Kohana的应用程序,这将打破,因为在的.htaccess 文件中的RewriteBase将是错误的。有没有一种方法可以让我有一个条件的的.htaccess 文件类似于一个我的引导,使其使用正确的RewriteBase?
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?
推荐答案我不认为有一种方法可以有一个条件的RewriteBase 。我想到在Apache中的唯一方法是把的RewriteBase 指令到一个<地点> 标签,但是这是仅在httpd.conf文件本身,而不是在.htaccess文件。
I don't think there is a way to have a conditional RewriteBase. The only way in Apache that comes to mind is putting the RewriteBase directive into a <Location> tag but that is only available in httpd.conf itself, not in .htaccess files.
我通常在这种情况下,什么是定义在当地不同的 AccessFileName 环境,例如 htaccess.txt 。该文件将包含本地重写规则,而的.htaccess 包含服务器端的。
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.
更多推荐
Kohana3:不同的.htaccess的RewriteBase和Kohana的BASE
发布评论