Welcome Guest, Not a member yet? Register   Sign In
routes working only in local
#11

I also tried this configuration:
Code:
location /jobs/ {
    index index.php;
    root  myroute;
    if ($request_filename !~ (js|css|images|robots\.txt|index\.php.*) ) {
        rewrite ^/(.*)$ /index.php/$1 last;
    }
}
location ~ /jobs/index.php/ {
    include /etc/nginx/fastcgi.conf;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  myroute/index.php;
    fastcgi_param  REQUEST_URI      $request_uri;
    fastcgi_param  QUERY_STRING     $query_string;
    fastcgi_param  REQUEST_METHOD   $request_method;
    fastcgi_param  CONTENT_TYPE     $content_type;
    fastcgi_param  CONTENT_LENGTH   $content_length;
    fastcgi_pass   127.0.0.1:9000;
}

But you are blocked images and css file with a 404 error and also the controller still does not work ...
Reply
#12

(This post was last modified: 06-12-2015, 05:02 AM by StratoKyke.)

(06-10-2015, 03:31 PM)CroNiX Wrote: Codeigniter has nothing to do with the server it's being run on. The server, whether it's Apache, NGINX, LightHTTP, IIS or something else it needs to be set up to run the PHP application, whether it's CI or WordPress or something else. The application can't alter to webserver to "make itself run". No webserver runs PHP by default, except maybe PHP's built-in webserver.

Here's a working NGINX conf for a CI site:




Code:
server {
   listen 80;

   server_name YOUR_SERVER.com ;
   root /var/www/PATH_TO_SITE_ROOT;

   error_page 404 403 /404.html;

   location / {
       index index.html index.php; ## Allow a static html file to be shown first
       try_files $uri $uri/ @handler;
       expires 30d; ## Assume all files are cachable
   }

   ## These locations would be hidden by .htaccess normally
   location ^~ /application/        { deny all; }

   location  /. { ## Disable .htaccess and other hidden files
       return 404;
   }

   location @handler {
       rewrite / /index.php;
   }

   location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
       rewrite ^(.*.php)/ $1 last;
   }

   location ~ .php$ { ## Execute PHP scripts
       if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss

       expires        off; ## Do not cache dynamic content
       fastcgi_param  HTTPS $fastcgi_https;
       fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
       fastcgi_param  SITE_ENVIRONMENT development;
       fastcgi_pass   unix:/tmp/php-fpm.sock;
       include        fastcgi_params; ## See /etc/nginx/fastcgi_params
   }
}

The main things you would need to change with your values are:




Code:
server_name YOUR_SERVER.com ;
root /var/www/PATH_TO_SITE_ROOT;

and to set the site environment:




Code:
fastcgi_param  SITE_ENVIRONMENT development;

Ok, with this configuration:

PHP Code:
location /jobs/ {
 
index index.html index.php;
 
try_files $uri $uri/ @handler;
 
expires 30d;
}

location ^~ /jobs/application       deny all; }

location  /jobs/. {
 return 
404;
}

location @handler {
 
rewrite / /jobs/index.php;
}

location ~ .php/ {
 
rewrite ^(.*.php)/ $1 last;
}

location ~ .php$ {
 if (!-
e $request_filename) { rewrite / /index.php last; }
 
expires        off;
 
fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
 
fastcgi_param  SITE_ENVIRONMENT production;
 
fastcgi_pass   unix:/tmp/php-fpm.sock;
 include 
       fastcgi_params## See /etc/nginx/fastcgi_params


I return at the start point. 

With only default controller work and the all other controller return:
[Image: attachment.php?aid=244]

EDIT: The only controller that not work is my custom routes

Code:
$route['page/(:any)'] = 'page/thread/$1';
$route['acp'] = 'acp/user/login';
$route['acp/page/edit/(:any)'] = 'acp/page/edit/$1';
$route['acp/page/delete/(:any)'] = 'acp/page/delete/$1';
$route['acp/menu/edit/(:any)'] = 'acp/menu/edit/$1';
$route['acp/menu/edit/(:any)'] = 'acp/menu/delete/$1';

Infact if I create a simply controller it works.

I have to set something specific about nginx only for these controllers?

Attached Files Thumbnail(s)
   
Reply
#13

Please there is no one who can help me? I'm desperate!
Reply
#14

In routes.php Try replacing :any with .+

$route['login/(.+)'] = 'auth/login/$1';


It solved my problems.
http://www.codeigniter.com/user_guide/ge...uting.html

Posted from a tablet with one finger Smile
Reply
#15

(This post was last modified: 06-12-2015, 10:23 PM by StratoKyke.)

(06-12-2015, 06:40 PM)John_Betong Wrote: In routes.php Try replacing :any with .+

$route['login/(.+)'] = 'auth/login/$1';


It solved my problems.
http://www.codeigniter.com/user_guide/ge...uting.html

Posted from a tablet with one finger Smile


Nothing. I have not solved.


You use nginx? what is your setup?

'ACP' in my routes it is an directory. In different 'page' is a controller.
Reply
#16

I discovered something.

The problem is not dependent on the configuration of my vps. I tried to install cms-canvas developed in codeigniter and it works perfectly every routes works perfectly without any problems.

That problem could be in my small cms that makes it work on xampp but not on nginx?
Reply
#17

Apparently not. Unfortunately that cms works differently.

I do not know really what to do.
Reply
#18

The problem was resolved by renaming controllers.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB