Clean-URL rewrite rule with nested "location" and alias directive

Ben Johnson ben at indietorrent.org
Sun Nov 24 21:31:24 UTC 2013



On 11/23/2013 12:36 PM, Ben Johnson wrote:
>       location ^~ /stage/ {
>>         root /var/www/example.com/private/stage/web/;
>>         # The files are read from /var/www/example.com/private/stage/web/stage/
>>         index index.php index.html index.htm;
>>         try_files $uri $uri/ /stage/index.php?q=$uri;
>> 
>>         location ~ \.php$ {
>>           # use a different "root" here if you want; but make sure the php
>>           # files can be read from within "stage/" below that root.
>>           try_files $uri /stage/index.php?q=$uri;
>>           fastcgi_pass unix:/var/run/php5-fpm.sock;
>>           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
>>           include /etc/nginx/fastcgi_params;
>>         }
>>       }

Francis,

Yes! After making the changes you recommended on the filesystem
(enabling me to ditch "alias"), the staging site is now working
perfectly with a slight variation of the above configuration.

For the sake of academic curiosity, I would like to try some of the
alternate configurations that you cooked-up, but I'll save that for
later. For now, I'm just thrilled to have this working!

Again, I can't thank you enough for your patience, thoroughness, and
generosity with your time.

Best regards, and cheers to a working configuration!

-Ben



More information about the nginx mailing list