Welcome! Log In Create A New Profile

Advanced

back-reference from if() and rewrite?

ST
June 05, 2017 11:16AM
Hello,

I need to translate following rule from apache to nginx:

RewriteCond %{QUERY_STRING} id=([^&]*) [NC,OR]
RewriteCond %{QUERY_STRING} daily=([^&]*) [NC]
RewriteCond %{REQUEST_URI} !mobSpecCycle [NC]
RewriteCond %{REQUEST_URI} !mobSpecTheme [NC]
RewriteRule ^rss\/mobSpec([^\/]+)/?$ /rss/mobSpec$1/mobSpec$1_%1.html
[QSA,NC,L]

which, e.g. rewrites

/rss/mobSpecArticle/?id=26422

into

/rss/mobSpecArticle/mobSpecArticle_26422.html

I started as follows

if ($args ~ id=([^&]*)|daily=([^&]*)) {
rewrite ^/rss\/mobSpec([^\/]+)/?$ /rss/mobSpec$1/mobSpec$1_$2.html
last;
}

However I don't know how to backrefernce id=([^&]*) in the rewrite rule?
I put $2 there, but it doesn't work... apache has %1 for
back-referencing matches from the RewriteCond.

1. How do I back-referencing matches from if () in nginx within
following rewrite?

2. Any ideas how I can add the last two condition?
RewriteCond %{REQUEST_URI} !mobSpecCycle [NC]
RewriteCond %{REQUEST_URI} !mobSpecTheme [NC]

Thank you in advance!


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

back-reference from if() and rewrite?

ST June 05, 2017 11:16AM

Re: back-reference from if() and rewrite?

Ingo Lafrenz June 08, 2017 10:44AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 145
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