Reputation: 3816
I have a site configuration pointing to /var/www for a domain (https://somedomain.com/) but I want a location /clientfolder to be redirected to /home/clientfolder/website/
My issue is whenever a request comes in, such as https://somedomain.com/clientfolder/index.html the daemon is looking for a file at /home/clientfolder/website/clientfolder/index.html
So I tried to use the rewrite directive:
location /clientfolder {
rewrite ^/clientfolder/(.*)$ /$1 last;
root /home/clientfolder/website
}
But now https://somedomain.com/clientfolder/index.html loads the file at /var/www/index.html
Is there another directive than rewrite that would allow me to strip the "clientfolder" from the file path if the /clientfolder location was matched?
Update: I managed to get this to work, but it feels totally wrong:
location /clientfolder/website {
root /home;
}
location /clientfolder {
rewrite ^/clientfolder/(.*)$ /clientfolder/website/$1;
}
Upvotes: 1
Views: 35
Reputation: 49752
If URIs beginning with /clientfolder
are located in /home/clientfolder/website
, you should use an alias
directive.
For example:
location /clientfolder {
alias /home/clientfolder/website;
}
See this document for details.
Upvotes: 1