Problem using CODEIGNITER on Nginx server

1

My site was hosted on UOLHOST and worked perfectly with the following .htaccess

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)

RewriteRule ^(.*)$ index.php?r=$1 [L,QSA]

I'm migrating to an EC2 on Amazon and I'm going to use Nginx as a web server in conjunction with PHP-FPM.

Who made the site, said that his administration used CODEIGNITER.

I have changed config.php settings within / application / config and only the website works, its not admin.

I've tried this:

    server {
    listen 80;
    root /usr/share/nginx/html/meudominio.com.br;
    index index.php;
    server_name meudominio.com.br www.meudominio.com.br;
    access_log /var/log/nginx/meudominio.com.br.access;
    error_log /var/log/nginx/meudominio.com.br.error error;
    location / {
    try_files $uri /index.php?r=$uri&$args;
    }

    location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    }
    location /controle {
    }
    location ~ /\.ht {
    deny all;
    }
    }

The "CONTROL" folder is where the administration of the website is.

Alternatively, I created another block and a sub-domain pointing to the control folder. As below:

    server {
    listen 80;
    root /usr/share/nginx/html/meudominio.com.br/controle;
    index index.php;
    server_name adm.meudominio.com.br;
    access_log /var/log/nginx/meudominio.com.br.access;
    error_log /var/log/nginx/meudominio.com.br.error error;
    location / {
    try_files $uri /index.php?r=$uri&$args;
    }

    location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    }
    }

Accessing the administration of the website through the url adm.meudominio.com.br I can enter and view all the manageable items of the website.

However, when I upload images to the server, their path is modified, depending on the root that I set for the sub-domain.

  

/usr/share/nginx/html/yourdomain/control

When in fact I need the images to be sent based on the root "/usr/share/nginx/html/mydomain.com"

What's happening?

    
asked by anonymous 26.12.2015 / 00:37

1 answer

1

I was able to solve the problem by including the following lines

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

just above:

location ~ \.php$ {

With this, the system using CODEIGNITER behaved in APACHE using the .hataccess reported at the beginning of the publication.

    
30.12.2015 / 05:36