Error while I open CodeIgniter index.php page without parameters |
[eluser]gianluborza[/eluser]
Hi, I noticed that if I try to open the CodeIgniter main index page with the URL http://myip/index.php/ instead of http://myip/index.php the page returns the following errors: A PHP Error was encountered Severity: Notice Message: Undefined offset: 0 Filename: libraries/Router.php Line Number: 190 A PHP Error was encountered Severity: Notice Message: Undefined offset: 0 Filename: libraries/Router.php Line Number: 196 A PHP Error was encountered Severity: Notice Message: Undefined offset: 0 Filename: libraries/Router.php Line Number: 199 I fixed the problem adding in function _validate_request($segments) of libraries/Router.php the following controll (line 189): if($segments == null) { $segments[0]=''; }
[eluser]Colin Williams[/eluser]
What version of CI? I cannot replicate. In fact, I can do http://www.example.com/index.php//// and it works
[eluser]gianluborza[/eluser]
Version 1.6.3 If I try with one or many '/' I have the same problem... Maybe it is caused by a bad configuration of my WebServer. I attach a picture of the error.
[eluser]Colin Williams[/eluser]
My assumption is a poorly formed mod_rewrite implementation or something with routing. Are you using either mod_rewrite or routing?
[eluser]gianluborza[/eluser]
Probably you are right. Unfortunately I do not have access to the Apache configuration of the Web Host (I'm using a free host service). Thank you for the help :-)
[eluser]Unknown[/eluser]
I noticed this too, when I used the sample htaccess file from the documentation (in /user_guide/general/urls.html). RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt|user_guide) RewriteRule ^(.*)$ /index.php/$1 [L]
[eluser]darkbrian[/eluser]
same issue here - you can rid the warning by changing the error reporting in the config.php file
[eluser]Khoa[/eluser]
I think I know what is causing this problem. It works like this: The problem happens only on my home page when accessing the site on my host at the real domain: Code: http://www.mydomain.com/ Code: http://localhost/mydomain/ Code: http://www.mydomain.com/index.php Code: http://www.mydomain.com/login/ Code: if (file_exists(APPPATH.'controllers/'.$segments[0].EXT)) I will try to write an extension to this library to fix this and will post it here once finished. Anyone has any other suggestion about this bug? Khoa
[eluser]Khoa[/eluser]
I tried to write an extension to the library and it did not work but when I added the code straight into the core router class, it works! Here is my code: MY_Router.php Code: <?php The only thing that I add in is this block at the beginning of the function: Code: if (count($segments) == 0) But it keeps receiving the same error that offset 0 is not found in the following if checking. However, if I put above block straight into the router.php file, it works fine. So that means the block works, but my extension does not. What do I do wrong in extending the library here? Can anyone help me? For the sake of the project going live very soon, I have to put it inside the core lib but really want to move it out as an extension. Thanks.
[eluser]brandonrichards[/eluser]
Try this: In your .htaccess file: Comment out anything similar to: RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt|user_guide) RewriteRule ^(.*)$ /index.php/$1 [L] Add: <IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [QSA,L] </IfModule> Save it, upload it, Refresh the page |
Welcome Guest, Not a member yet? Register Sign In |