nginx rewrite rule under a subdirectory
try to use this, and please don't forget to replace root path!
location /main/ { root /full/path/from/root/main/; try_files $uri $uri/ /index.php?$args;}
I've set wordpress on my host in folder /main and got it's working with next settings:
location /main { index index.php; try_files $uri $uri/ /main/index.php?q=$uri;}root /path/to/webroot;
location ^~ /main { root /var/www/domain.com/html/wordpress; index index.php; try_files $uri $uri/ /main/index.php; location ~ \.php$ { try_files $uri =404; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass unix:/run/php/php8.0-fpm.sock; }}
You need to change the php8.0 to your current PHP version in use and the root /var/www/domain.com/html/wordpress
to your root directory where the subdirectory main
comes after subdirectory Wordpress
.