Welcome! Log In Create A New Profile

Advanced

Re: Questions about root and alias directives

Valentin V. Bartenev
January 20, 2017 11:32AM
On Friday 20 January 2017 12:15:30 Nikolaos Milas wrote:
> Hello,
>
> I need a config which includes multiple different physical paths.
>
> So I have:
>
> server {
>
> listen [::]:80;
> ...
> root /var/webs/wwwmain/www/;
>
> index index.php index.html index.htm;
>
> ...
>
> location / {
> try_files $uri $uri/ /index.php?$args;
> }
>
> location /museum/ {
> root /var/webs/wwwmuseum/;
> }
>
> ...
>
> }
>
> Now, when I request "http://www.example.com/museum/", the above config
> produces a request for the following path:
>
> /var/webs/wwwmuseum/museum/index.php
>
> I think this is the expected result, according to the documentation.
>
> If I change the last part to use an alias directive:
>
> location /museum/ {
> alias /var/webs/wwwmuseum/;
> }
>
> then the evaluated path becomes:
>
> /var/webs/wwwmain/www/museum/index.html
>
> The alias directive does not seem to have any effect. (Why is that so?)
>
[..]

The answer to your question is likely in the parts of the configuration
that you've skipped.

Please note, that the "index" directive produces internal redirects.

In the second case, it looks like your request is redirected to
"/museum/index.html" and then handled by some other location.

wbr, Valentin V. Bartenev

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Questions about root and alias directives

Nikolaos Milas January 20, 2017 05:16AM

Re: Questions about root and alias directives

Valentin V. Bartenev January 20, 2017 11:32AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 193
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready