如何设置的.htaccess为Kohana的正确,因此有在URL中有丑“的index.php /”?

StackOverflow https://stackoverflow.com/questions/966429

  •  12-09-2019
  •  | 
  •  

2小时后,现在我无法得到它的权利。

在Kohana的安装是直属我的域,即 “ http://something.org/

相反 http://something.org/index.php/welcomde/index我想有例如 http://something.org/welcome/index

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

请,有人可以为一个标准的Kohana系统提供他的工作的.htaccess?

有帮助吗?

解决方案

我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'] = '';

其他提示

这是我们的.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]

请注意,我们有我们的应用程序,系统和模块的目录网站根目录的所有外。

在某些主机,我认为specficially的CGI模式下运行PHP的时候,你必须改变

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

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

在您的htaccess的。因此,基本上可以使用 Kohana的推荐设置,只需更换与index.php/$1 index.php?/$1

尝试此mod_rewrite的规则:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !^index\.php index.php%{REQUEST_URI} [L]

对于那些谁得到“禁止错误” 403 OSX上使用默认的.htaccess一定要加在.htaccess中的第一行

选项+了FollowSymLinks

3.2的Kohana具有不同的惯例。如果您在Kohana_URL看,你会发现下面的函数签名:

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

其中$指数是默认为TRUE。通过传递一个$指数FALSE你删除的index.php参考。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top