【发布时间】:2018-10-16 08:41:17
【问题描述】:
我关注的最后一个在这里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/.htaccessRewriteEngine 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的每个实例替换为AllowOverride All- 启用重写模式:
sudo a2enmod rewrite - 最后再次重启apache2服务。
毕竟,我再次访问我的 url http://localhost/homerent/Login 我仍然得到 404 not found。
我不知道这有什么问题。
【问题讨论】:
-
如果不启用,请确保启用了 mod rewrite 并重新启动 apache。
-
@prasannaputtaswamy,我确实使用了这个命令
sudo a2enmod rewrite,但它仍然无法正常工作。
标签: php apache codeigniter-3 ubuntu-17.10