codeigniter 删除index.php:错误404在Linux上,但在Windows上工作正常

syqv5f0l  于 5个月前  发布在  PHP
关注(0)|答案(3)|浏览(50)

在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),它工作正常,但我会删除它。

zmeyuzjn

zmeyuzjn1#

Linux是区分大小写的。记住你写的目录和文件名的大小写。你应该在任何文件中写文件或目录名,与文件或目录所属的完全相同。
请检查user_authentification的文件/目录。此外,控制器/型号的第一个字母应该是大写(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>

字符串

hjzp0vay

hjzp0vay2#

管理员已发现错误。虚拟主机中存在错误。
.htaccess文件从未执行。
谢谢大家的帮助

ijnw1ujt

ijnw1ujt3#

如果尚未创建其他.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/

不要忘记重启服务器

相关问题