6

2小时后,我无法正确处理。

Kohana 安装可以直接在我的域下访问,即“ http://something.org/

而不是http://something.org/index.php/welcomde/index我想要像http://something.org/welcome/index这样的 URL

我的 .htaccess 完全搞砸了。它实际上是下载附带的标准 example.htaccess。它几乎没用。在 kohana 页面上有一个教程“如何删除 index.php”。它也真的没用,因为它甚至不会谈论如何删除它。完全混乱。

请问,有人可以为标准的 kohana 安装提供他的工作 .htaccess 吗?

4

6 回答 6

9

我的 htaccess 看起来像这个例子。

RewriteEngine On

RewriteBase /

RewriteRule ^(application|modules|system) - [F,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

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

但是您还必须将config.php文件更改为:

$config['index_page'] = '';
于 2009-06-09T03:55:32.797 回答
5

这是我们现在的 .htaccess 文件,它似乎正在工作。

RewriteEngine On

# 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,L]

请注意,我们的应用程序、系统和模块目录都在 Web 根目录之外。

于 2009-06-08T21:07:43.447 回答
4

在某些主机上,我认为特别是在 CGI 模式下运行 PHP 时,您必须更改

RewriteRule ^(.*)$ index.php/$1 [L]

RewriteRule ^(.*)$ index.php?/$1 [L]

在你的 htaccess 中。所以基本上你可以使用kohana 推荐的设置,只需替换index.php/$1index.php?/$1

于 2009-06-08T20:58:39.643 回答
2

试试这个 mod_rewrite 规则:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !^index\.php index.php%{REQUEST_URI} [L]
于 2009-06-08T19:12:19.247 回答
1

对于那些在 OSX 上使用默认 .htaccess 获得“禁止错误”403 的人,请务必将其添加为 .htaccess 中的第一行

选项 +FollowSymLinks

于 2010-03-06T17:44:20.147 回答
0

Kohana 3.2 有不同的约定。如果您查看 Kohana_URL,您会发现以下函数签名:

public static function site($uri = '', $protocol = NULL, $index = TRUE)

其中 $index 默认为 TRUE。通过传递 $index FALSE 您将删除 index.php 引用。

于 2012-07-17T03:15:22.400 回答