Welcome Guest, Not a member yet? Register   Sign In
CI4 routes doesn't work on production server
#1

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?
Reply
#2

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...
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#3

(This post was last modified: 11-13-2021, 10:49 AM by fujael.)

(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.
Reply
#4

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-chec...ot-working
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#5

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




Theme © iAndrew 2016 - Forum software by © MyBB