Forum: NGINX Question about variables

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F5a6ed477b109fe6acc11a5a8f87e7e8?d=identicon&s=25 mike (Guest)
on 2008-12-03 23:44
(Received via mailing list)
I'm going to try this myself - but I'm not sure it can be done.

Our website is structured as

/en-us/stuff
/ru-ru/stuff

etc.

However, the underlying filesystem does not have these virtual locale
paths. It basically is "/stuff"

I want to be able to use

if (!-e $request_filename) {
    rewrite ^/(.*) /foo.php?q=$request_uri last;
}

or

error_page 404 = /foo.php?q=$request_uri;

However, it is trying to use /en-us/stuff for the request filename
instead of just /stuff - is there some way I can set a variable and
remove a portion of the URI, so it is something like

set $customvar someregexhere;
if(!-e $customvar) {
   rewrite ^/(.*) /foo.php?q=$request_uri last;
}

I tried doing a rewrite to remove the /en-us/ etc... but that does not
appear to change the $request_filename (from what I can tell, I am
still trying to mess with it some more) - I still need the original
URI or some way to grab the locale code inside of PHP, so I can't
strip that off and forget about it completely.

Anyone have any ideas?
F5a6ed477b109fe6acc11a5a8f87e7e8?d=identicon&s=25 mike (Guest)
on 2008-12-03 23:54
(Received via mailing list)
I think I answered my own question :)

rewrite ^/(en-us|zh-cn|ru-ru)/(.*) /$2 last;

Seemed to fix it. I can use
if (!-e $request_filename) {}
properly now.

Now hopefully my expires location block and such does not interfere :)
This topic is locked and can not be replied to.