DeathLace Share Posted June 23, 2017 (edited) I've been trying to add a new rule in my nginx server configuration but just can't get it to work. I've stripped out the stuff that doesn't matter (SSL certificate locations, etc), and this is what i have: server { root /var/www/stage/stage.domain.com; index index.php; server_name stage.domain.com; location /subfolder { root /var/www/stage/stage.domain2.com; try_files $uri $uri/ =404; if (!-f $uri){ set $rule_2 1$rule_2; } if ($rule_2 = "1"){ rewrite /. /index.php last; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; } } location / { try_files $uri $uri/ =404; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; } } The part I'm adding is the "location /subfolder {" part. Basically the site already exists, but doesn't have any rewrite happening at all. This new subfolder, I need to load from a different root, and have a rewrite rule to always load the root index.php file no matter what. Every thing I've tried results in one of three things happening: 1. Loads the index.php file, but doesn't run PHP (downloads the file) 2. Runs php, but doesn't load the rewrite rule, so returns a 404 error 3. Ignores everything, and loads the index.php file from the base domain "location /" block. Any ideas? Link to post Share on other sites
Recommended Posts