几天前我开始学习kohana并且使用我的Zend Framework,我的学习经历似乎很快,直到遇到几个问题。
首先,我在Windows 7中启动了该项目(使用linux ubuntu 12.04进行双启动)。在我开始使用kendo ui向管理员应用添加更多页面之前,我知道每个链接都没问题。我添加了几个路由来处理子文件夹中的控制器,并使用?bla=dkll&second=lkdjf
形式的查询字符串处理url(由kendo网格用于根据用户与网格的交互发送未知数量的参数)。
第一个问题:在Windows下我会访问除根/
之外的任何网址,例如localhost/admin/
(管理员是我在htdocs中的文件夹)它给了我
ERROR: HTTP_Exception_404 [ 404 ]: The requested URL / was not found on this server
:
83
try
84{
85if ( ! class_exists($prefix.$controller))
86{
87throw new HTTP_Exception_404('The requested URL :uri was not found on this server.',
88array(':uri' => $request->uri()));
89}
90
91// Load the controller using reflection
92$class = new ReflectionClass($prefix.$controller);
第二个问题:在ubuntu下我不仅有第一个问题,但我甚至无法点击其他urls
localhost/admin/useraccess/login
问题:
是与第一个相关的第二个问题(显然不包括'/'未找到的问题) 我已经启用了ubuntu mod_rewrite并且kohana安装页面全部为绿色。
有没有其他设置我忘了启用哪个在Windows php(xampp)中启用了不在ubuntu上?
找到我的.htaccess / logs / boostrap here
感谢您阅读并帮助
答案 0 :(得分:2)
我假设你的应用程序的根文件夹是'admin'。在bootstrap.php中你应该有:
Kohana::init(array(
'base_url' => '/admin',
'index_file' => FALSE,
));
同样在你的bootstrap.php中,默认路由应该是最后一条路径:
Route::set('default', '(<controller>(/<action>(/<id>)))')
->defaults(array(
'controller' => 'index',
'action' => 'index',
));
您添加的其他路线应位于默认路线上方。
答案 1 :(得分:2)
我和你有同样的问题,我的kohana在我的Windows机器上运行良好。但是当我将它迁移到Ubuntu时,我遇到了路由问题。这是我的坏,我忘了编辑我的apache conf。您可以在/ etc / apache2 / sites-enabled / 000-default
中查看conf文件Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all /Directory>
将'AllowOverride None'编辑为'AllowOverride All'并重新启动您的apache网络服务器。
像魔术一样工作!!
答案 2 :(得分:1)
添加到digby's note:All class file names and directory names are lowercase.
我注意到了一些小事,但没有什么可以解释你遇到的问题:
您期望哪种控制器被路由?目前它应该是控制器_...嗯......我用我的小眼睛窥探一个错字! 'susbcribers'而不是'订阅者'。所以目前你将被路由到Controller_Susbcribers :: index()。
如果你想要Controller_Useraccess :: index()而不是Controller_Subscribers :: index()(假设你修正了拼写错误)删除第一个kendogrid路由,因为'kendogrid'和'default'都匹配一个空URI。
PS。我假设你使用3.2