我知道有很多像这样的问题,但我应用了所有内容,并且找不到正确的方法。CodeIgniter 2.1.4 - 路由在服务器中不起作用
的是的.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.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的启用。
在本地主机中,一切正常,但当我上传到服务器,只有索引工作(你看到的第一页),但当我想“移动”在网上,我有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');
OR
echo base_url('Products'); // I have in config/routes.php ---> $route['Products'] = "Products_controller/index";
任何人都可以帮我吗?我错过了什么?
谢谢。
什么是您的托管服务提供商? .htaccess因托管服务提供商而异。 –
我的托管服务提供商是hostinet。我问他“mod_rewrite”,他们说它已被激活,所以我可以使用它。 – danigonlinea
试试我的答案,让我知道发生了什么。 –