Welcome! Log In Create A New Profile

Advanced

Rewrite nginx

Posted by slurpderp 
Rewrite nginx
November 03, 2011 05:48PM
Good evening,
I would like to know how to rewrite a url with nginx correctly

For example:
I want http://domain/?subtopic=herp&derp=this to rewrite to http://domain/herp/derp/this

I've tried looking at so many guides with no success
Re: Rewrite nginx
November 03, 2011 11:35PM
slurpderp Wrote:
-------------------------------------------------------

> I want http://domain/?subtopic=herp&derp=this to
> rewrite to http://domain/herp/derp/this
>

if ($args ~ subtopic=(?<subtopic>[^&]+)&derp=(?<derp>[^&]*)) {
rewrite ^ /$subtopic/derp/$derp? last;
}

Put the above into your server {} configuration (do not put it into location {} block)

Haven't tested this one, but it should work ok.

Andrejs



Edited 2 time(s). Last edit at 11/03/2011 11:37PM by locojohn.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 137
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready