Welcome! Log In Create A New Profile

Advanced

Understanding alias (used as rewrite)

E.B.
June 22, 2015 06:06AM
Hi, I'm confused about the details of "alias" used as
a kind of rewrite (which should be more efficient as
I understand it, as long as its appropriately used).

I found I can do this:

location = /path/number/one.html {
alias /some/other/path/script.php;
include fastcgi.conf;
}

So I was confucsed why this not working:

location ^~ /my-long-prefix-goes-here {
alias /another/different/path/anotherscript.php;
include fastcgi.conf;
}

In other words, alias of exact location match does
a cheap "rewrite" perfectly. But now I want to match
addresses like:

/my-long-prefix-goes-here
/my-long-prefix-goes-herexxx
/my-long-prefix-goes-here/
/my-long-prefix-goes-here/filename

Only the first one works, the others are 404. Is
Nginx adding the tail end of the matched prefix
to the aliased location? I tried to make my alias:

alias /another/different/path/anotehrscript.php?;

so the stuff on the end turns into a query arg which
php can ignore. But that didn't work.

I also tried to use regex to match the location:

location ~ ^/my-long-prefix-goes-here {

But now NONE of the addresses work - even the
exact match is 404. Why??

I found this was the only way to make it work:

root /another/different/path;
rewrite ^(.*)$ /anotehrscript.php break;

In this situation is rewrite the only solution?

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

Understanding alias (used as rewrite)

E.B. June 22, 2015 06:06AM

Re: Understanding alias (used as rewrite)

Edho Arief June 22, 2015 02:22PM

Re: Understanding alias (used as rewrite)

E.B. June 22, 2015 04:34PM

Re: Understanding alias (used as rewrite)

Edho Arief June 22, 2015 11:20PM

Re: Understanding alias (used as rewrite)

E.B. June 24, 2015 02:46AM

Re: Understanding alias (used as rewrite)

Edho Arief June 24, 2015 06:52AM

Re: Understanding alias (used as rewrite)

Francis Daly June 24, 2015 11:44AM

Re: Understanding alias (used as rewrite)

E.B. June 24, 2015 08:08PM

Re: Understanding alias (used as rewrite)

E.B. June 24, 2015 08:20PM

Re: Understanding alias (used as rewrite)

Francis Daly June 25, 2015 01:54PM

Re: Understanding alias (used as rewrite)

E.B. June 27, 2015 03:06AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 234
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