簡體   English   中英

codeigniter 3 - 在linux上刪除index.php:錯誤404但在Windows上正常工作

[英]codeigniter 3 - remove index.php : error 404 on linux but work fine on windows

Linux上的錯誤404,但在Windows上工作正常。 是什么造成的?

我使用本教程: http//www.tutora.fr/apprendre-codeigniter/les-controleurs

application / config / routes.php:

$route['default_controller'] = 'welcome';
$route['translate_uri_dashes']  = FALSE;
$route['login'] = 'user_authentification/user_authentification';

的application / config / config.php文件:

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
$config['subclass_prefix'] = 'CORE_';

Windows上的本地托管(XAMPP)在url mysite.dev/login上運行良好。

Linux上的實時托管在url mysite.pro/login上產生404錯誤。

如果我添加index.php (mysite.pro/index.php/login),它工作正常,但我會刪除它。

如果尚未創建其他.htaccess文件,請在項目根目錄中創建.htaccess文件。

將代碼粘貼到代碼下面。

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /projectname
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>

你可以嘗試這個鏈接http://addictors.in/remove-index-php-from-url-in-codeigniter/

別忘了重啟服務器

希望能幫助到你。

Linux區分大小寫。 請記住,在哪種情況下您編寫了目錄和文件名。 您應該在任何文件或目錄所屬的文件中寫入文件或目錄名稱。

請檢查user_authentification的文件/目錄。 此外,控制器/模型的第一個字母應該是cap(codeigniter要求)。 請檢查您是否正確編寫了controller/model名稱。

更新

將以下片段放在.htaccess文件中:

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteCond $1 !^(index\.php|resources|robots\.txt)
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>

管理員發現了錯誤。 虛擬主機出錯。
.htaccess文件從未執行過。
感謝大家的幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM