Laurent
Laurent

Reputation: 987

Nginx, exception in rewrite rule

I am stuck with a specific server configuration.

Until now, no problem.

I want to do not redirect mobile users to m.domain.com on a specific page.

This is what I have now:

if ($mobile_rewrite = perform) {
    rewrite ^ http://m.domain.com redirect;
    break;
}

I want something like (pseudo code):

if ($mobile_rewrite = perform && Location != /path/* ) {
    rewrite ^ http://m.domain.com redirect;
    break;
}

Thank you for your tips!

Upvotes: 0

Views: 1290

Answers (2)

Van Long Ha
Van Long Ha

Reputation: 1

if ($request_uri !~ "^/blog/\w+$")
 { 
   set $mobile_rewrite do_not_perform;
 }        

and i think this work.

Upvotes: 0

Laurent
Laurent

Reputation: 987

I actually found something using the $request var:

set $mobile_rewrite = [...] (perform or do_not_perferm)
if ($request ~* "path") {
    set $mobile_rewrite do_not_perform;
}
if ($mobile_rewrite = perform) {
    rewrite ^ http://m.domain.com redirect;
    break;
}

Maybe not the best solution, but it works!

Upvotes: 1

Related Questions