我的DigitalOcean服务器出了问题。我正在使用Ubuntu。 CodeIgniter返回给我404但是在我的localhost上它很好。这是我的mod_rewrite
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /localhost/x/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
路由和配置都很好。
答案 0 :(得分:1)
我得到了答案。重命名控制器以使大写的第一个字母。
示例:main.php到Main.php
我不知道为什么,但它有效!希望有所帮助!
答案 1 :(得分:0)
在我看来你忘记在Apache .conf文件中启用mod_rewrite使用sudo a2enmod rewrite
然后sudo service apache2 restart
启动
mod_rewrite的。
有关详细信息,请参阅数字海洋教程: