How do I make this work?
location ~ /~someapp(.*)$ { alias /home/someapp/root$1; try_files $uri
/~someapp/err404.htm; }
The try_files never catch the $uri (nor $1) and returns 500 (redirection
cycle)
Am I ‘forced’ to use error_page in this case?
This works:
location ~ /~someapp(.*)$ { alias /home/someapp/root$1; error_page 404
/~someapp/err404.htm; }
and without regex the error_page and try_files seem to be completely
ignored:
neither
location /~someapp/ { alias /home/someapp/root/; error_page 404
/~someapp/err404.htm; }
nor
location /~someapp/ { alias /home/someapp/root/; try_files $uri
/~someapp/err404.htm; }
works.
On Wed, Jun 17, 2009 at 9:57 AM, Edho P Arief[email protected]
wrote:
works.
I also find using this works
location ~ /~someapp(.*)$ {
root /home/someapp/root/;
try_files $1 /~someapp/err404.htm;
}
On Wed, Jun 17, 2009 at 10:35 AM, Edho P Arief[email protected]
wrote:
This works:
/~someapp/err404.htm; }
–
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
so, alias and try_files just doesn’t work together?
On Wed, Jun 17, 2009 at 09:57:41AM +0700, Edho P Arief wrote:
works.
If request is “/~someapp/one”, then this location
location /~someapp/ {
alias /home/someapp/root/;
try_files $uri /~someapp/err404.htm;
}
will test /home/someapp/root/one existence.
As to
location ~ /~someapp(.*)$ {
alias /home/someapp/root$1;
try_files $uri /~someapp/err404.htm;
}
this “alias” with captures is special case.
A “root” is always just prefix to URI and “try_files” tests “root$uri”.
An “alias” without captures replaces location part in URI with
the “alias” value, and “try_files” tests “alias/modified_uri”
An “alias” with captures replaces a whole URI with the “alias” value,
and “try_files” tests “alias/$uri”, and $uri is surpplus here.
You need just to pass empty value to “try_files”:
location ~ /~someapp(.*)$ {
alias /home/someapp/root$1;
try_files "" /~someapp/err404.htm;
}
2009/6/18 Igor S. [email protected]:
  location /~someapp/ { alias /home/someapp/root/; try_files $uri
will test /home/someapp/root/one existence.
An “alias” without captures replaces location part in URI with
the “alias” value, and “try_files” tests “alias/modified_uri”
An “alias” with captures replaces a whole URI with the “alias” value,
and “try_files” tests “alias/$uri”, and $uri is surpplus here.
You need just to pass empty value to “try_files”:
  location ~ /~someapp(.*)$ {
    alias /home/someapp/root$1;
    try_files “”  /~someapp/err404.htm;
  }
Thanks for the explanation (and it works). It’d be nice to have this
kind of information available in documentation somewhere ![:slight_smile: :slight_smile:](https://www.ruby-forum.com/images/emoji/apple/slight_smile.png?v=12)
Or maybe I (or someone else) can update the wiki… (the alias part is
outdated)
2009/6/18 Igor S. [email protected]:
  location /~someapp/ { alias /home/someapp/root/; try_files $uri
will test /home/someapp/root/one existence.
An “alias” without captures replaces location part in URI with
I just noticed it doesn’t work properly (bug?)
location ~ ^/~([^/]+)(..php)$ {
alias /home/$1/public_html$2;
try_files “” @404;
include php_params;
}
location ~ ^/~([^/]+)(.)$ {
alias /home/$1/public_html$2;
try_files “” @404;
}
php_params:
fastcgi_pass 127.0.0.1:8000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
from phpinfo():
_SERVER[“SCRIPT_NAME”] ^/~([^/]+)(..php)$
_SERVER[“REQUEST_URI”] /~edho/
_SERVER[“DOCUMENT_URI”] ^/~([^/]+)(..php)$
…still in regex form?
as for static file, it always returned with mime type of
application/octet-stream ( http://pastebin.com/m7d2c8f6e )
On Fri, Jun 19, 2009 at 3:33 PM, Edho P Arief[email protected]
wrote:
_SERVER[“SCRIPT_NAME”] Â ^/~([^/]+)(.*.php)$
full config: http://pastebin.com/m2be37d60
Is this a bug?
On Fri, Jun 19, 2009 at 3:30 PM, Edho P Arief[email protected]
wrote:
Am I ‘forced’ to use error_page in this case?
nor
A “root” is always just prefix to URI and “try_files” tests “root$uri”.
            try_files “” @404;
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
full config: http://pastebin.com/m2be37d60
Tip: I had overcame alias+try_files problem by using symlinks insted of
aliases.
Bests,
Andor
Posted at Nginx Forum: