[英]codeigniter controllers not working
我是Web开发的新手,所以这个问题可能非常简单。
我已经安装并运行了xampp,并且正在使用netbeans最新版本。
我目前正在尝试遵循一个教程,这个教程要求我制作一些控制器,但我能成功加载的唯一页面是index.php。
我在application / controllers文件夹中创建了一个新的控制器:
<?php
class Blog extends CI_Controller {
public function index()
{
echo 'Say something';
}
}
?>
并尝试通过它访问它
http://localhost/Something/Blog
但是我收到一个错误:
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.6.3
PS
http://localhost/Something is loading fine.
我编辑了.htaccess文件:
RewriteEngine on
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ." index.php/$0 [PT,L]
我一直在谷歌搜索解决方案3小时,我将不胜感激任何帮助:)
将.htaccess文件更改为:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
另外,尝试访问:
http://localhost/Something/index.php/Blog
试试这个 :
本地主机/事/ index.php文件/ controllername
还要在浏览器URL中小写controller class
和method
名称。 你可以使用:
http://localhost/index.php/something/blog
添加htaccess这段代码我的帮助
RewriteEngine on
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.