在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/$1 [L]
RewriteCond $1 !^(index.php|public|.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php?$1
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>
需要启用mod_rewrite。请参阅 https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_rewrite-for-apache-on-centos-7