我相信您的问题是缺少“?” 在这条线上:
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
添加这个'?直接在“index.php”之后
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
另外,根据我的经验,我会去掉 RewriteBase 上的斜杠,并将其添加到 $config['base_url'] 参数中,然后让 CI 为您完成这项工作:
$config['base_url'] = 'http://yourwebsite.com/demo/';
-instead of-
$config['base_url'] = 'http://yourwebsite.com/demo';
这是我在 CI 中使用了一段时间的 .htaccess 设置,它对我很有帮助:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase / # TODO: add a folder name here if the application is not in web root
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
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>