我知道有很多这样的问题,但我应用了所有内容,但我找不到正确的方法 .
.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";
有人可以帮帮我吗?我错过了什么?
谢谢 .
3 回答
虽然.htaccess有时依赖托管服务器,但你可以尝试使用它,让我们知道 . 用以下代码替换.htaccess代码:
而已 .
以上应该工作 - 确保您的
.htaccess
在您要运行的子目录中 .还要确保基本目录中没有冲突的
.htaccess
规则 .最后,我得到了一个关于这个主题的解决方案 . 它不是关于.htaccess问题,是一个真正的转储和简单的错误 .
感谢你们 .