【发布时间】:2018-07-04 11:19:17
【问题描述】:
此应用程序在 Codeigniter 版本 = 3.1.3 中构建。在构建此应用程序时,可以使用此 htaccess 文件正常工作,但今天当我运行此应用程序并遇到此类错误时。
运行我的 codeigniter 网站时,htaccess 文件无法重写我的 index.php 网址。因此,显示未找到请求的 URL 错误。
正常工作的网址 => localhost/Magpie/index.php/Front_master/aboutus.html
错误网址 => localhost/Magpie/index.php/Front_master/aboutus.html
这是我的 htaccess 代码:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /Magpie/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
控制器文件:Front_master.php
<?php
class Front_master extends CI_Controller {
public $result = array();
public function __construct() {
parent::__construct();
//load models
$this->result["getContact"] = $this->GetInformation->getContact();
$this->result["getLogo"] = $this->GetInformation->getLogo();
$this->result["getSlide"] = $this->GetInformation->getSlide();
$this->result["getServices"] = $this->GetInformation->getServices();
$this->result["getContent"] = $this->GetInformation->getContent();
$this->result["getPropertyListing"] = $this->GetInformation->getPropertyListing();
$this->result["getBestDeal"] = $this->GetInformation->getBestDeal();
$this->result["getTeam"] = $this->GetInformation->getTeam();
}
public function index() {
$data = array();
$data['title'] = 'Home Page';
$data['header'] = $this->load->view('frontview/header', $this->result, TRUE);
$data['slider'] = $this->load->view('frontview/slider', $this->result, TRUE);
$data['dashboard'] = $this->load->view('frontview/dashboard', $this->result, TRUE);
$data['footer'] = $this->load->view('frontview/footer', '', TRUE);
$this->load->view('frontview/master', $data);
}
public function aboutus() {
$data = array();
$data['title'] = 'About Us';
$data['header'] = $this->load->view('frontview/header', $this->result, TRUE);
$data['dashboard'] = $this->load->view('frontview/about_us', $this->result, TRUE);
$data['footer'] = $this->load->view('frontview/footer', $this->result, TRUE);
$this->load->view('frontview/master', $data);
}
}
【问题讨论】:
-
你得到的错误是什么?
-
在此服务器上找不到请求的 URL /Magpie/Front_master/aboutus.html。
-
也显示你的代码
-
你可能在 apache.conf 文件中需要这个“AllowOverride All”
-
sudo a2enmod rewrite 试试这个命令并重启你的 apache
标签: .htaccess ubuntu-16.04 codeigniter-3