Codeigniter 404 can't find index.php (only on real server, not on virtual server)

北城余情 提交于 2019-12-11 18:35:45

问题


I got a working webpage with CodeIgniter. I did now just upload it to my webserver and it gives me a 404 error.

The browser address is "web-page.com/folder/en/about"

The baseurl in the config is "web-page/folder/"

Also this is in the config.php, I did try AUTO but it does not work either.

$config['index_page'] = "";
$config['uri_protocol'] = "QUERY_STRING";

The index.php is in "web-page.com/folder/"

My htaccess is in "web-page.com/folder/.htaccess"

The content of the .htaccess is

AddCharset utf-8 .css .html .xhtml
Options +FollowSymlinks
RewriteEngine on
RewriteBase  /folder/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(index\.php|images|media|layout|css|libs|robots\.txt)
RewriteRule ^(.*)$ /folder/index.php?/$1 [L]

Do you have any tip, any idea, what can I try to do? I did check all the rights, even with 777 it does not work.

Thanks in advance.

Lukas


回答1:


I know this should be a comment, but apparently I don't have enough rep yet. Who is your web host? That could sometimes throw a wrench in the whole process.

I know GoDaddy requires some different config settings for CodeIgniter to work right without the 'index.php'.

If it is, you'll need to change your uri_protocol config item to QUERY_STRING.

You can leave your index_page setting blank, but you'll need to update your htaccess file to something like this:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L] 



回答2:


Okey, stupid, stupid me. I got it.

The error was in my "routes.php" I hadt to lowercase the default controller from

$route['default_controller'] = "Base";

to:

$route['default_controller'] = "base";

My offline server did work with it though. Thanks for the support.




回答3:


It is at least worth mentioning, I was getting a 404 http code despite the fact that I could print data to screen. The problem came when trying to pass POST data between forms.

Long story short, make sure you have apache rewrite enabled:

apache2ctl -t -D DUMP_MODULES

OR, look for 'mod_rewrite' under "Loaded Modules" under "apache2handler" in phpinfo().

To enable apache rewrite:

sudo a2enmod rewrite

Hope this helps someone!




回答4:


Try

$config['uri_protocol'] = REQUEST_URI 

changing between either REQUEST_URI or QUERY_STRING worked for me




回答5:


if someone read this post again, don't forget check all uppercase and lowercase letter in url



来源:https://stackoverflow.com/questions/2641627/codeigniter-404-cant-find-index-php-only-on-real-server-not-on-virtual-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!