Welcome! Log In Create A New Profile

Advanced

Re: Understanding alias (used as rewrite)

E.B.
June 24, 2015 02:46AM
Thanks for your ongoing helps! I hope someone
can advise further

> >> You're probably looking for this
> >>
> >> fastcgi_param SCRIPT_FILENAME /another/different/path/anotehrscript.php;
> >
> > Excellent point! Thanks you!
> > However, what if the alias was NOT to a php file? Is using
> > rewrite the only solution - alias not able to working? What
> > is alias doing to cause 404?
>
> This config works for me.
>
> location ~ ^/test {
> alias /data/public_html/somefile.php;
>
> include fastcgi.conf;
>
> fastcgi_pass 127.0.0.1:8900;
> }

Yes, I had also got similar to work, but
only for the exact match uri-- the first
in my list of possible uris that must work:

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

I still get 404 for the last 3. That's why
I thinking it was adding the end of the original
uri to the alias redirect. but Im not sure.

(I used prefix match not regex match but I
now tried your version with regex and get same
result)

> Check what your error log says to find out why it returns 404.

Im not getting anything in my log I dont know
why (access log shows the requested uri but
I cant find the file not found error). I checked
php log too and basic nginx error log. I have a
access and error log set for this domain. Is
that where the file not found error should be going?

> Also the question mark you put will become part of file name php look
> for (it'll look for 'file.php?' instead of 'file.php'.

I was using the ? to try and avoid unknown file
lookups because I thought the part of the uri
after the matching location prefix was being
added to the aliased location. I thought I could
pass it as a query string to PHP so I could ignore
it that way.

But you help clarify that it won't work that way
so I understand partly why I am getting 404, thank
you.

Part of what is not clear is if/when alias will have
the rest of the uri after the match prefix added to
it?? The doc:

http://nginx.org/en/docs/http/ngx_http_core_module.html#alias

says nothing, but it begins to appear to me that if
you end the aliased location with / then it will have
the rest of the original uri added to it, but if you
don't end the alias with / then it will be taken without
changes.

If that's not right, can someone explain?

And if that is right, why isn't it documented (a
simply and imporant key feature should have that
documentde!

_______________________________________________
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: 163
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