CodeIgniter Forums
CI4 routes doesn't work on production server - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: CI4 routes doesn't work on production server (/showthread.php?tid=80488)



CI4 routes doesn't work on production server - fujael - 11-08-2021

Hi
I noticed CI4 auto routing acts differently on nginx/apache2 server. Let's guess we have controller files - 
Code:
Home.php
Blog.php

The `Blog.php` has a method ::details.

Now, if we run `php spark serve`, with the localhost:8080 it works perfectly. I can reach /blog/details-page without errors.
But this doesn't work on nginx/apache/xampp any server other than spark/php development server.

Any help?



RE: CI4 routes doesn't work on production server - includebeer - 11-08-2021

It should work. Your server must be misconfigured.
"this doesn't work" doesn't mean anything. What does it do? What's the error message? Without any info it can be anything...


RE: CI4 routes doesn't work on production server - fujael - 11-13-2021

(11-08-2021, 01:54 PM)includebeer Wrote: It should work. Your server must be misconfigured.
"this doesn't work" doesn't mean anything. What does it do? What's the error message? Without any info it can be anything...

Hi
Thanks, I didn't made any special config for nginx server. It is - 

Code:
server {
    server_name  *.****.com;
    root          /home/user/web_test/htdocs;
    index          index.php index.html;

    location ~ \.php$ {
    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    #try_files $uri =404;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    #include snippets/fastcgi-php.conf;
    include fastcgi_params;
    add_header 'Cache-Control' no-store always;
    }
    location ~ /\.ht {
    deny all;
    }
    location ~ (\.log$|\.bkp){
        deny all;
    }
    error_page 502 /index.php?e=502;
    error_page 403 /index.php?e=403;

    location / {
    try_files $uri $uri/ /index.php?/$request_uri;
    }


}
server {

    server_name  *.**.com;
    listen 80;


}

(11-08-2021, 01:54 PM)includebeer Wrote: It should work. Your server must be misconfigured.
"this doesn't work" doesn't mean anything. What does it do? What's the error message? Without any info it can be anything...

Also I should clarify -

I am trying to use autoroute feature. Guess I have `Blog` Controller with method `details`. If I manually set the route ->add('/blog/details/(:any)') then it works without trouble. But I want it to works automatically because I already have a method called `details`. Why I should implicitly configure it on `Routes.php` for the production server.
In localhost:8080 or `php spark serve` I didnot need to specify paths/routes to Routes.php but production level I have to specify. This is the issue here.


RE: CI4 routes doesn't work on production server - includebeer - 11-13-2021

It's not a good idea to mix autoroute with configured routes. Choose one or the other.
Maybe go through this check list, it may be a problem with file permissions, etc: https://includebeer.com/en/blog/the-checklist-of-things-to-check-when-your-codeigniter-4-web-application-is-not-working


RE: CI4 routes doesn't work on production server - fujael - 11-14-2021

Thank you man, I'll try only autoroute with logging checks.