【发布时间】:2016-03-21 07:47:40
【问题描述】:
我的 DigitalOcean 服务器出现问题。我正在使用 Ubuntu。 CodeIgniter 返回给我 404 但在我的本地主机上一切都很好。这是我的 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>
路由和配置都很好。
【问题讨论】:
-
你在服务器上打开 mod_rewrite 了吗?您使用的是什么版本的 Apache?
-
是的,我也做了 sudo a2enmod 重写,但仍然无济于事。我用的是 2.4.7 我也重启了 apache2 服务。
-
RewriteBase - 通常是 /
-
这就是@Svetlio 所说的——你确定有名为
localhost的目录吗?默认情况下,在 DO Ubuntu droplet 上,您的 Web 位置应位于/var/www/html中,即/在.htaccess文件中。
标签: php apache .htaccess codeigniter mod-rewrite