在 Codeigniter Digital Ocean 中出现 404 错误

Getting 404 error in Codeigniter Digital Ocean

Digital Ocean 中托管了一个 Codeigniter 应用程序。登录后出现404错误。

$config["base_url"] = "http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["SCRIPT_NAME"]);

$config["index_page"] = "index.php";

$config["uri_protocol"] = "REQUEST_URI";

htacess 代码是

<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php/ [L]

RewriteCond  !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php?
RewriteRule ^(.*)$ index.php?/ [L,QSA]
</IfModule>

需要启用 mod_rewrite。参考 https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_rewrite-for-apache-on-centos-7