I have a site nginx.asdf.com:8082
which contains a CMS built using PHP (CodeIgnitor framework). I also have a similar site running under nginx.asdf.com:8082/ghjkl/
. My Nginx configuration works for nginx.asdf.com:8082
but not for nginx.asdf.com:8082/ghjkl/
.
My current Nginx configuration is:
server {
listen 8082 default_server;
listen [::]:8082 default_server;
server_name nginx.asdf.com;
root /var/www/nginx.asdf.com/ghjkl/;
index index.html index.php index.htm;
# if your default controller is something other than "welcome" you should change the following
if ($request_uri ~* ^(/pages/views(/index)?|/index(.php)?)/?$)
{
rewrite ^(.*)$ / permanent;
}
# removes trailing "index" from all controllers
if ($request_uri ~* index/?$)
{
rewrite ^/(.*)/index/?$ /$1 permanent;
}
# removes trailing slashes (prevents SEO duplicate content issues)
if (!-d $request_filename)
{
rewrite ^/(.+)/$ /$1 permanent;
}
# removes access to "system" folder, also allows a "System.php" controller
if ($request_uri ~* ^/system)
{
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
# unless the request is for a valid file (image, js, css, etc.), send to bootstrap
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
# catch all
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
include snippets/fastcgi-php.conf;
}
# deny access to apache .htaccess files
location ~ /\.ht
{
deny all;
}
}