我关注的最后一个是这里How to remove index.php from codeigniter in UBUNTU [duplicate]
我有一个看起来像这样的控制器:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Login extends CI_Controller {
public function index()
{
$this->load->view('login.html');
}
}
当我通过这个 URL: 访问它时http://localhost/homerent/Login
,我得到 404 not found。
我按照参考链接中的上述答案
- $config['index_page'] = '';
- 重启apache2服务:sudo /etc/init.d/apache2 reload
将以下代码添加到
/var/www/html/my_ci_site/.htaccess
RewriteEngine on RewriteBase / RewriteCond $1 !^(index\.php|static|robots\.txt|favicon\.ico|uploads|googlexxxxxxxx\.html|mobile.html) RewriteRule ^(.*)$ index.php/$1 [L]
替换/etc/apache2/apache2.conf中
AllowOverride None
to的每个实例AllowOverride All
- 启用重写模式:
sudo a2enmod rewrite
- 最后再次重启apache2服务。
毕竟,我再次访问我的网址,http://localhost/homerent/Login
但仍然找不到 404。
我不知道这有什么问题。