Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect to URL outside the Angular app but on the same domain

Tags:

angular

Within angular routing is there any way to redirect to an external directory on the same domain. I have a WordPress blog and angular app I want it to use same domain rather than a subdomain.

Example

  • http://example.com --> Angular App

  • http://example.com/blog --> Wordpress Blog

Please help me with your suggestions.

like image 309
Kesara Wimal Avatar asked Sep 11 '18 08:09

Kesara Wimal


People also ask

Can I redirect a domain to a specific URL?

Under the Domain category, choose the Redirects menu. You'll see the Create a Redirect section. Here, you'll need to fill in which URL you want to Redirect and where you want it to Redirect To. Make sure your information is correct and choose the right connection protocol – HTTP or HTTPS.

How do I route a URL to another URL?

Click the URL Redirects tab. In the upper right, click Add URL redirect. In the right panel, select the Standard or Flexible redirect type. A standard redirect is used to redirect one URL to another.

Can you redirect a URL to a specific page?

Redirects allow you to forward the visitors of a specific URL to another page of your website. In Site Tools, you can add redirects by going to Domain > Redirects. Choose the desired domain, fill in the URL you want to redirect to another and add the URL of the new page destination.


1 Answers

I understand why you wanna do this with Angular router. Navigating to an external url from an Angular application is something quite easy. Using window.location or an anchor tag is straight forward, but it has a big disadvantage, it bypasses the Angular Router.

@Adrian proposed a nice and generic way of navigating to an external url using the Angular Router which is written inside Using the Angular Router to navigate to external links. I like his implementation which looks clean and correct. He prepared the final result in stackblitz too.

like image 75
Amirhossein Mehrvarzi Avatar answered Sep 19 '22 06:09

Amirhossein Mehrvarzi