Trololinlo
Trololinlo

Reputation: 1

NGINX Mod_rewrite, Subfolder redirect to folder

I'm novice and i have a problem with the rewrite mod in NGINX.

I give you the environement: I have 2 app:

both app need to be a Mod_rewrite, so i use this :

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

This work completely for the first app, BUT, when I go on the second app /atri/ this load all the app like the same root of the first app in the folder /www/. Do you have an idea to separate the 2 app in the conf?

For information I use codeigniter.

Thanks for your reply.

Upvotes: 0

Views: 1768

Answers (2)

Arfan Mirza
Arfan Mirza

Reputation: 696

location /atri/ {
alias  /var/www/html/atri/;
try_files $uri $uri/ /atri/index.php;

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_index   index.php;
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    include /etc/nginx/fastcgi_params;
    fastcgi_param   SCRIPT_FILENAME $request_filename;
}

}

try this!

Upvotes: 0

Richard Smith
Richard Smith

Reputation: 49812

Try:

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

See this document for more.

Upvotes: 1

Related Questions