NGINX Rewrite Condition if Something is at END of URL?

Alright,

I have a lot of incoming links that would activate a cookie and then forward onto a particular page. The url typically looks like this:

Nowt that returns a 404 error dude to my new url structure, which I’m forcing a rewrite to. The correct link is now:

Here is the rewrite I’m tying to give an idea:


location /trailer/ {
     rewrite ^/?trailer/([-0-9a-zA-Z]+)/([-0-9a-zA-Z]+)$ /$1/$2 permanent;
}

location /hdplus {
     rewrite ^/?trailer/([-0-9a-zA-Z]+)/([-0-9a-zA-Z]+)/hdplus$ /$1/$2 permanent;
}

Obviously that was a long shot, but hopefully shows what I’m trying to do.

All feedback appreciated!
Ryan

The ‘/hdplus’ is actually a regex depending on what you feed nginx so you should be able to handle it there. See http://nginx.org/en/docs/http/ngx_http_core_module.html#location for some pointers.