我知道有很多像這樣的問題,但我應用了所有內容,並且找不到正確的方法。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
試試我的答案,讓我知道發生了什麼。 –