I don't understand why the below Nginx config allows me to get to my index.php ok:
http://localhost:8080/nesting/index.php
but all dependencies of that page, like css, img keep pointing at http://localhost:8080/... So everything looks broken. Likewise when moving on to another page it keeps pointing at the root url.
How to make the subdirectory persistent?
server {
listen 8080;
server_name localhost;
root /var/www/html;
index index.php index.html index.htm;
# compression setting
gzip_vary on;
gzip_proxied any;
gzip_comp_level 5;
gzip_min_length 100;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml
application/xml application/xml+rss text/javascript text/json;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.*)$;
set $path_info $fastcgi_path_info; # because of bug http://trac.nginx.org/nginx/ticket/321
try_files $fastcgi_script_name =404;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $path_info;
fastcgi_param PATH_TRANSLATED $document_root$path_info;
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_param SERVER_NAME $http_host;
}
location /nesting/ {
alias /var/www/html/nesting/;
index admin.php index.php;
}
index.phpfile along with its assets is placed in any nested directory, the resulting HTML document should refer its assets using relative URLs (e.g../style.cssorstyle.css) rather than absolute ones (e.g./style.css).DocumentRoot "/var/www/html" <Directory "/var/www/html"> Options +Indexes +FollowSymLinks +ExecCGI AllowOverride All Require all granted </Directory> Alias /nesting"/var/www/html/nesting/" <Directory "/var/www/html/nesting/"> Options +Indexes +FollowSymLinks +ExecCGI AllowOverride All Require all granted </Directory>