在
Linux上出现错误404,但在Windows上工作正常。是什么原因造成的?
我使用本教程:http://www.tutora.fr/apprendre-codeigniter/les-controleurs
应用程序/配置/路由.php :
$route['default_controller'] = 'welcome';
$route['translate_uri_dashes'] = FALSE;
$route['login'] = 'user_authentification/user_authentification';
应用程序/配置/配置.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(,它可以正常工作,但我会删除它。
Linux 区分大小写。请记住您编写了目录和文件名的情况。您应该在任何文件中写入文件或目录名称,与文件或目录所属的名称完全相同。
请检查user_authentification
的文件/目录。此外,控制器/型号的第一个字母应该是大写字母(代码点火器要求(。请检查您是否正确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 文件,请在项目根目录中创建 .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/
不要忘记重新启动服务器
希望对您有所帮助。
管理员发现了错误。虚拟主机中出现错误。
.htaccess 文件从未执行过。
谢谢大家的帮助。