[英]How to set up .htaccess for Kohana correctly, so that there is no ugly “index.php/” in the URL?
2个小时后,我无法做对。
Kohana安装可直接在我的域名下访问,即“ http://something.org/ ”
而不是http://something.org/index.php/welcomde/index我希望有http://something.org/welcome/index这样的网址
我的.htaccess完全搞砸了。 它实际上是下载附带的标准example.htaccess。 这几乎没用。 在kohana页面上有一个教程“如何删除index.php”。 它也没用,因为它甚至不会谈论如何删除它。 完全令人困惑。
请问,有人可以提供他的工作.htaccess用于标准的kohana安装吗?
我的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]
请注意,我们的应用程序,系统和模块目录都在Web根目录之外。
在某些主机上,我认为特别是在CGI模式下运行PHP时,你必须改变
RewriteRule ^(.*)$ index.php/$1 [L]
至
RewriteRule ^(.*)$ index.php?/$1 [L]
在你的htaccess。 所以基本上你可以使用kohana推荐的设置 ,只需用index.php/$1
替换index.php/$1
index.php?/$1
试试这个mod_rewrite规则:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !^index\.php index.php%{REQUEST_URI} [L]
对于那些在OSX上使用默认.htaccess获得“禁止错误”403的人,请确保添加为.htaccess中的第一行
选项+ FollowSymLinks
Kohana 3.2有不同的约定。 如果您查看Kohana_URL,您将找到以下函数签名:
public static function site($uri = '', $protocol = NULL, $index = TRUE)
其中$ index默认为TRUE。 通过传递$ index FALSE,您将删除index.php引用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.