我是Web开发的新手,所以这个问题可能很简单。
我已经安装并运行了 xampp,并且正在使用 netbeans 最新版本。
我目前正在尝试遵循一个教程,该教程需要我制作几个控制器,但我唯一可以成功加载的页面是 index.php。
我在应用程序/控制器文件夹中制作了一个新的控制器:
<?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
附言
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
试试这个:
localhost/Something/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]