Local and absolute redirects
Redirects can be local and absolute. Local redirects replace a single URL segment with a different one. Absolute redirects replace the whole URL.
If the redirectTo
value starts with a /
, then it is an absolute redirect. The next example shows the difference between relative and absolute redirects.
[ { path: ':folder/:id', component: ConversationCmp, children: [ { path: 'contacts/:name', redirectTo: '/contacts/:name' }, { path: 'legacy/messages/:id', redirectTo: 'messages/:id' }, { path: 'messages/:id', component: MessageCmp } ] }, { path: 'contacts/:name', component: ContactCmp } ]
When navigating to /inbox/33/legacy/messages/44
, the router will apply the second redirect and will change the URL to /inbox/33/messages/44
. In other words, the part of the URL corresponding to the...