0

I have the case that need to rewrite the URL

The old URL:

https://abc.local/ui/navigation/data/vsphere.core.folder.monitor.eventsView?objectId=urn:vmomi:Folder:group-d1:bffc54a1-3add-487a-8c5a-4d03f759d1fe

The new URL:

https://abc.local/ui/

Could you please help me. How can I do it?

Many thanks

RobC
  • 16,905
  • 14
  • 51
  • 62

1 Answers1

0
map $request_uri $redirect {
    default 0;
    /ui/navigation/data/vsphere.core.folder.monitor.eventsView?objectId=urn:vmomi:Folder:group-d1:bffc54a1-3add-487a-8c5a-4d03f759d1fe  https://abc.local/ui/;

}


server {
    if ($redirect) {
    return 301 $redirect;
}

As Richard say, this should work. Map the request uri outside of the server bracket, and then inside it set the if with a redirect to your wanted url.

flaixman
  • 622
  • 6
  • 14
  • It seem that the long URI here is not accepted by Nginx, it can not start the nginx service if i use this URL in the map the request uri. Do you have any solutions for this? Thanks a lot /ui/navigation/data/vsphere.core.folder.monitor.eventsView?objectId=urn:vmomi:Folder:group-d1:bffc54a1-3add-487a-8c5a-4d03f759d1fe https://abc.local/ui/; – An Tran Thanh Linh Oct 16 '19 at 08:00
  • https://stackoverflow.com/questions/1067334/how-to-set-the-allowed-url-length-for-a-nginx-request-error-code-414-uri-too Does this help? – flaixman Oct 16 '19 at 11:14