Problem with aliases

Francis Daly francis at daoine.org
Thu Jul 1 05:57:21 UTC 2021


On Wed, Jun 30, 2021 at 07:31:43PM -0400, yosef wrote:

Hi there,

> Im trying to use several blocks in my server using the server IP as server
> name (no domain yet), each block points to a folder containing Wordpress. I
> dont know what Im doing wrong because instead of running index.php nginx is
> download the file.

In nginx, one request is handled in one location{}. Only the
configuration in (or inherited into) that location matters.

(One http request can become more than one (sub)request within nginx.)


> location ^~ /proj1  {
>      alias /var/www/proj1/public_html;
>     try_files $uri $uri/ /index.php?q=$uri&$args;
>  }

"^~" means "prefix match, and do not look at parallel regex matches".

So a request for /proj1/index.php will be handled in this location{}. And
this location has no fastcgi_pass or similar directive, so it will use
"serve from the filesystem".

Probably the simplest fix is to copy the "location ~ \.php$ {" block to
be inside each of the "location ^~" blocks.


Note also -- if the request is for /proj1/missing, the try_files will
use the subrequest /index.php?q=/proj1/missing& -- is that what you want,
instead of (e.g) /proj1/index.php?q=/proj1/missing& ?

Good luck with it,

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list