Kohana3:不同的.htaccess的RewriteBase和Kohana的BASE

编程入门 行业动态 更新时间:2024-10-08 04:31:35
本文介绍了Kohana3:不同的.htaccess的RewriteBase和Kohana的BASE_URL用于开发和生产环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在我的 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

本文发布于:2023-11-02 06:15:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551594.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:htaccess   RewriteBase   BASE   Kohana

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!