• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Everything throws 404 errors

#1
Hi Everyone!
This is my first post. I'm really new to CodeIgniter (new as in "just downloaded it for the first time") so I have a very rookie question

I uploaded the codeigniter files to my test server (running with nginx+phpfpm). 
According to the general recommendation in the installation instructions page, I moved the application and system directories on level above my web root so it looks pretty much like this:


/home/webuser/my_project/
- /home/webuser/my_project/system/
- /home/webuser/my_project/application/
- /home/webuser/my_project/www/ <--- this is the web root

I modified the main index.php file as follows:
$system_path = '/home/webuser/my_project/system';
$application_folder = '/home/webuser/my_project/application';

After doing that, I tried to access the site on my browser and I got the expected CodeIgniter welcome page (so far so good!), so I thought everything was a-OK.

Here comes the problem: 
According to the default "welcome" controller, the controller is mapped to
mysite.com/index.php/welcome
mysite.com/index.php/welcome/index

but none of the above work (they throw a 404 error). I think I have checked everything, but I can't figure it out.

I can see the codeigniter welcome page at both mysite.com and mysite.com/index.php so I'm almost sure I'm making a really rookie mistake

EDIT: forgot to add, my Nginx configuration points the root to /home/webuser/my_project/www/
If I change to /home/webuser/my_project/ (no /www/), the welcome page keeps working but even the user_guide stops working

Can you please give me a hand? Thanks in advance
Javier
Reply

#2
Update:
I managed to get most of CI working by making some changes to my nginx.conf file

In case it helps anyone with the same issue, this is what I did (if this is not the best way to do this, I'd appreciate any thoughts, specifically considering this makes my controllers and views work, but breaks my local /user_guide directory which now throws a 403 Forbidden error)
1.- In my nginx.conf (/etc/nginx/nginx.conf) file, within the http section I added:
# mydomain.com
server {
listen 80;
listen [::]:80;

server_name mydomain.com;
set $base /home/webuser/my_project/www;
root $base;

# index.php
index index.php;

# index.php fallback
location / {
try_files $uri $uri/ /index.php?$query_string;
}

# handle .php
location ~ \.php$ {
try_files $uri =404;

# fastcgi
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_ADMIN_VALUE open_basedir=$base/:/usr/lib/php/:/tmp/;
fastcgi_intercept_errors off;

fastcgi_buffer_size 128k;
fastcgi_buffers 256 16k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;

# default fastcgi_params
include fastcgi_params;
}

for some reason, this seems to work, although I'm yet to figure out why/how this breaks the /user_guide directory (which I can live with anyway).
I'm now an almost happy camper, since I can create a new controller from scratch and it works like a charm
Javier Larroulet
Reply

#3
If you moved the application and system folders above into the root you
need to edit the index.php and change the folder paths to them

../application

and

../system
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.