Welcome! Log In Create A New Profile

Advanced

Re: Rewrite rules with NGinx

António P. P. Almeida
January 20, 2013 12:24PM
On 20 Jan 2013 17h35 CET, mikydevel@yahoo.fr wrote:

> ----- Mail original -----
>
>> De : Francis Daly <francis@daoine.org>
>>
>> Hi there,
>>
>> Untested, but: it feels nicer to avoid rewrite if possible.
>
> Hello Francis,
> Thank you for your answer.
>
>>>   Action 1:   I would like that when people access to
>>> www.domain.org/nginx the system
>> queries the webpage www.domain.org/page.php?arg=nginx
>>
>>   location = /nginx {    # proxy_pass or fastcgi_pass and
>> fastcgi_param, or whatever is appropriate   }
>>
>> "appropriate" depends on which non-nginx thing you use to process
>> php.
>
> I have not installed anything like that at the moment but I'll use
> fastcgi I think. I'm not sure I fully understand your answer though.
>
>>>   Action 2:   For people who try to access to
>>> www.domain.org/page.php?arg=nginx, they are
>> redirected to www.domain.org/nginx
>>
>>   location = /page.php {
>>    if (#this_should_redirect) {
>>     return 302 /nginx;
>>    }
>>    # proxy_pass or fastcgi_pass, or whatever is appropriate
>>   }
>>
>> "this_should_redirect" might be based on $arg_arg, or on
>> $query_string,
>> or on something similar.
>
> According to your answer I should write something like this
> location = /page.php {
> if ($arg_arg = nginx) {
>      return 302 /nginx;
>      }
> # proxy_pass or fastcgi_pass, or whatever is appropriate
> }
>
>
>
>> What should happen for /page.php?arg=other ?
> I didn't think about this case but if arg=other, I would like the
> redirection to go to www.domain.org/http
>
>> And for /page.php?arg=nginx&other?
> I'm not sure I understand but the arguements provided will be
> arg=nginx&language=ru. So yes there could be more than one
> argument. But my Apache setting has only one argument at the moment
> and I'd like to move from Apache to Nginx.

I'm not sure I understand what you want to do. It seems you'll get a
redirect loop. But anyway, try this (untested):

map $arg_arg$arg_language $redirect {
default 0;
nginxru 1;
## Add as many lines as arg_arg and language combinations needed...
}

location = /page.php {
error_page 418 =200 /nginx;
if ($redirect) {
return 418;
}
## FCGI content handler here...
}


location = /nginx {
if ($status != 200) {
return 302 /page.php?$query_string;
}
try_files /page.php?$query_string =404;
}

--- appa

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

Redirect specific query to a page

OndanomalA January 18, 2013 08:22PM

Re: Redirect specific query to a page

António P. P. Almeida January 18, 2013 08:54PM

Re: Redirect specific query to a page

OndanomalA January 19, 2013 09:46AM

Re: Redirect specific query to a page

António P. P. Almeida January 19, 2013 01:00PM

Re: Redirect specific query to a page

OndanomalA January 19, 2013 08:30PM

Re: Redirect specific query to a page

António P. P. Almeida January 19, 2013 09:44PM

Re: Redirect specific query to a page

Vadim Lazovskiy January 20, 2013 08:02AM

Rewrite rules with NGinx

miky January 20, 2013 10:24AM

Re: Rewrite rules with NGinx

Francis Daly January 20, 2013 10:52AM

Re: Rewrite rules with NGinx

miky January 20, 2013 11:36AM

Re: Rewrite rules with NGinx

Francis Daly January 20, 2013 12:02PM

Re: Rewrite rules with NGinx

António P. P. Almeida January 20, 2013 12:24PM

Re: Redirect specific query to a page

OndanomalA January 20, 2013 07:18AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 70
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready