【发布时间】:2014-07-25 09:03:50
【问题描述】:
我知道有很多这样的问题,但我应用了所有方法,但找不到正确的方法。
.htaccess 是:
RewriteEngine On
RewriteBase /NewWebsite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /NewWebsite/error.php
</IfModule>
在 config/config.php 中:
$config['base_url'] = 'https://mydomain.com/NewWebsite/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO'; // I change it with REQUEST_URI and PATH_INFO but it don't work
在服务器中,mod_rewrite 已启用。
在 localhost 中,一切正常,但是当我将其上传到服务器时,只有索引有效(您看到的第一页)但是当我想在网络上“移动”时,出现 404 错误,找不到页面。
我将展示一个控制器以及如何调用它以更改为另一个视图。
class Products_controller extends CI_Controller {
public function index()
{
$this->load->helper('url');
$this->load->helper('html');
$this->load->view('products.php');
}
}
从索引,我称之为:
echo base_url('Products_controller/index');
或
echo base_url('Products'); // I have in config/routes.php ---> $route['Products'] = "Products_controller/index";
有人可以帮助我吗?我错过了什么?
谢谢。
【问题讨论】:
-
您的托管服务提供商是什么? .htaccess 因托管服务提供商而异。
-
我的托管服务提供商是 hostinet。我问他“mod_rewrite”,他们说它已激活,所以我可以使用它。
-
试试我的回答,让我知道发生了什么。
标签: .htaccess codeigniter routing codeigniter-2 codeigniter-routing