我花了很多时间寻找答案,但没有发现有同样问题的人:)。
我的本地版本很好(在ampps上运行),没有index.php的url运行得很好。我的本地文件夹和prod文件夹都在子文件夹中,所以它就像:
http://localhost/ci/
http://website.com/cms_ci/
但当我把文件夹放在prod服务器上时,主页正在工作,但如果我想访问http://website.com/cms_ci/content/我得了404分。如果我继续http://website.com/cms_ci/index.php/content/,它正在工作。
以下是我的配置和htaccess文件的设置:
config.php
$config['base_url'] = 'http://localhost:8080/cms/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
$config['url_suffix'] = '';
HTACCESS
Options -Indexes
RewriteEngine on
RewriteCond $1 !^(index'.php|assets/|robots'.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
当然,在我的产品配置文件中,我已经更改了
$config['base_url'] = 'http://localhost:8080/cms/';
至
$config['base_url'] = 'http://www.website.com/cms_ci/';
我试过各种htaccess文件,但现在有点卡住了。
提前感谢
试试这个htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
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>
ErrorDocument 404 /index.php
</IfModule>
你可以试试这个-
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index'.php|public|img|images|js|fonts|assets|robots'.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
这应该有效!