I have these URL's: /event/kind/thomas-de-stoomlocomotief/562 and I want to rewrite these urls to: /event/562/kind/thomas-de-stoomlocomotief (so basically position of numerics is changed...) how can I do this in nginx? I tried something like this: location /event { rewrite ^([a-zA-z-_]+)/([a-zA-z-_]+)/([0-9]+).*$ http://www.liveat.nl/event/$3/$1/$2 permanent; } but doesnt seem to be working :S