Hello everyone.
I am having problems appending an additional GET parameter to a request received. Let's say I have an URL like this:
http://1.2.3.4/wrapper/wrapper.html?viewer_id=555&viewer_type=2&secret=1234&language=0&referrer=profile&lc_name=1234
What I would like to get is to append a new GET parameter skip_maintenance when viewer_id equals to 555. So I would like to see something like
http://1.2.3.4/wrapper/wrapper.html?viewer_id=555&viewer_type=2&secret=1234&language=0&referrer=profile&lc_name=1234&skip_maintenance
I have tried many different ways around my config and found "if" construction fits my needs enough. But when the actual rewrite happens many weird things appears. What do I have now is this piece of config file:
-----------------------------------------------------------------------------------------------
server {
server_name _;
listen 80;
error_log /var/log/nginx/site-error.log debug;
access_log /var/log/nginx/site-access.log main;
location / {
root /usr/share/site/www_content/active/;
index index.html index.htm;
if ($args ~ user_id=555) {
rewrite ^ http://$server_addr$uri$is_args$args&skip_maintenance? break;
}
}
}
-----------------------------------------------------------------------------------------------
This config almost make things look like what I need. "If" part works as it should but when it comes to rewrite part I am getting this error: "The page isn't redirecting properly"
In error log I can see:
2011/08/04 11:48:35 [notice] 2934#0: *1 rewritten redirect: "http://1.2.3.4/wrapper/wrapper.html?viewer_id=555&viewer_type=2&secret=1234&language=0&referrer=profile&lc_name=1234&skip_maintenance&skip_maintenance&skip_maintenance&skip_maintenance&skip_maintenance&skip_maintenance&skip_maintenance&skip_maintenance&skip_maintenance&skip_maintenance&skip_maintenance&skip_maintenance&skip_maintenance&skip_maintenance&skip_maintenance&skip_maintenance&skip_maintenance&skip_maintenance&skip_maintenance&skip_maintenance&skip_maintenance"
So I have repeatable parameter here and I cannot get rid of this anyhow. I've tried rewrite permanent, last, with and without "?" at the end but with no luck. If I cut off "http://$server_addr" part I am getting full path to wrapper.html file with 404.
Any clues or ideas to get it work will be greatly appreciated.
My Nginx is 0.8.53