0

我正在使用 kohana 部署我的站点,这是测试站点 -localhost/koh,我使用 htaccess 删除索引。我能够成功地将它放在 www.site.com/koh 之类的东西中,但我正在努力将它放在根文件夹中,并使其与 htaccess 一起使用,或者我如何使其工作,方法是在根目录中放置索引和将所有其他文件保存在 koh 文件夹中?有人可以帮忙吗?谢谢

4

3 回答 3

1

这是您的问题的答案:

Kohana 根以外的部署等等

于 2009-12-11T07:13:13.180 回答
0

在您的情况下,这就是您的索引文件的外观,并放置在根文件夹下:

/**
 * The directory in which your application specific resources are located.
 * The application directory must contain the bootstrap.php file.
 *
 * @see  http://kohanaframework.org/guide/about.install#application
 */
$application = './koh';

/**
 * The directory in which your modules are located.
 *
 * @see  http://kohanaframework.org/guide/about.install#modules
 */
$modules = './koh/modules';

/**
 * The directory in which the Kohana resources are located. The system
 * directory must contain the classes/kohana.php file.
 *
 * @see  http://kohanaframework.org/guide/about.install#system
 */
$system = './koh/system';

在下面查看我的 htaccess,以了解您的 htaccess 应该是什么样子的示例。我的是 example.htaccess 的修改版本。强制 301 重定向到不带斜杠的 uri。

以下是我为 Kohana 构建部署的方式。它允许您使用一组核心文件来拥有多个应用程序。

www/
  apps/
    web/
      cache/
      classes/
      config/
      logs/
      media/
      messages/
      pub/
        index.php
        .htaccess
        robots.txt
  lib/
    modules/
    system/

这是我修改后的 .htaccess

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /

RewriteCond %{REQUEST_URI} (.*)$
RewriteRule ^(.+)/$ /$1 [R=301,L]

# Protect hidden files from being viewed
<Files .*>
    Order Deny,Allow
    Deny From All
</Files>

# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b - [F,L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]

这是 index.php 中的相关行

/**
 * The directory in which your application specific resources are located.
 * The application directory must contain the bootstrap.php file.
 *
 * @see  http://kohanaframework.org/guide/about.install#application
 */
$application = '../';

/**
 * The directory in which your modules are located.
 *
 * @see  http://kohanaframework.org/guide/about.install#modules
 */
$modules = '../../../lib/modules';

/**
 * The directory in which the Kohana resources are located. The system
 * directory must contain the classes/kohana.php file.
 *
 * @see  http://kohanaframework.org/guide/about.install#system
 */
$system = '../../../lib/system';

注意:此设置要求您配置 Web 服务器以访问每个应用程序。

于 2011-11-18T16:18:58.697 回答
0

假设您正在运行 v3 ......这些步骤应该让您朝着正确的方向前进:

将 index.php 放在您希望 Kohana 运行的文件夹中(在您的情况下,是根公共 html 文件夹)。

在 index.php 中,确保 $application、$modules 和 $system 的路径正确。(它们可以是绝对的或相对的(来自 index.php 的位置。))例如,要将应用程序文件夹保持在 webroot 的上方,您可以使用“../application”,等等模块和系统。

在 bootstrap.php 中,检查 base_url 的设置是否适合您的环境(将其设置为“/”)。

最后,确保 .htaccess 中的 RewriteBase 也设置为“/”。

于 2011-10-25T17:27:53.707 回答