【问题标题】:Kohana 3.0 installation problems - New controller issuesKohana 3.0 安装问题 - 新控制器问题
【发布时间】:2011-08-01 10:48:15
【问题描述】:

我一直在尝试在自己的 WAMP 服务器上安装 Kohana,但遇到了一些死胡同。我一直按照here 的说明进行操作,直到修改 .htaccess 文件; 我按指定重定向,但随后收到“内部服务器错误”,说明这是配置错误。我已经尝试了一堆组合,但我仍然得到同样的错误。

我发现的唯一工作方法是不包括 .htaccess 文件,而只是正确地将 bootstrap.php 指向正确的路径。 这呈现了我的welcome.php 控制器示例,但是,然后我尝试创建一个新的控制器并输入特定路径(mysite/controller_name),但出现404 错误。

任何想法我哪里出错了?

bootstrap.php -

Kohana::init(array(
'base_url'      => '/shiftrunner/kohana-shiftrunner/', 
'index_file'    => ''
));

.htaccess - # 开启 URL 重写 重写引擎开启

# Installation directory 
RewriteBase /shiftrunner/kohana-shiftrunner 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.* index.php/$0 [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]

【问题讨论】:

  • 请注意,我已将此安装放置在子目录中,例如根/some_project/kohana
  • Kohana 是在子文件夹还是在根目录中运行?我们可以看看你的 .htaccess 吗?我们能看到 bootstrap.php 中关于你的“base_url”(你给 Kohana::init 的数组)的部分吗?
  • Bootstrap.php - codeKohana::init(array( 'base_url' => '/shiftrunner/kohana-shiftrunner/', 'index_file' => '' ));code
  • .htaccess - # 打开 URL 重写 RewriteEngine On # 安装目录 RewriteBase /shiftrunner/kohana-shiftrunner 保护隐藏文件不被查看 Order Deny,Allow Deny From All # 保护应用程序和系统文件不被查看 RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L] # 允许直接显示任何存在的文件或目录 RewriteCond %{REQUEST_FILENAME} ! -f RewriteCond %{REQUEST_FILENAME} !-d # 将所有其他 URL 重写为 index.php/URL RewriteRule .* index.php/$0 [PT]
  • 嗨,如上所述,它在一个子文件夹中

标签: php .htaccess controller kohana config


【解决方案1】:

您的 RewriteBase 应该是 /shiftrunner/kohana-shiftrunner/ 并带有以下斜线,与您的引导程序中的 base_url 完全相同。

index_file 应设置为 false,如果您不希望它显示,而不是 ''

如果上述方法不起作用,我也会尝试更换

RewriteRule .* index.php/$0 [PT]

RewriteRule .* index.php [L]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-11-01
    • 1970-01-01
    • 2013-09-27
    • 1970-01-01
    • 2014-06-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多