The better solution:
location ~ ^/phpmyadmin(?:/(.*))?$ {
alias /home/phpmyadmin/$1;
}
Ensure that server has permissions to /home/phpmyadmin
first.
Explanation of difference with accepted answer:
It's all about regular expressions.
First of all, the ^
char means that you want to match from beginning of string and not somewhere in the middle. The $
at the end means matching to the end of the string.
The (?:)
means non-capturing group - we don't want it in the capturing results, but we want to simple group some chars. We group it like this, because we want the /
char to be a nonsignificant part of the child path, and not a significant part of the parent path.