Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove # in url in angular 5?

Actually i am using angular 5 for my project, I need to remove # from my url. here is my url http://localhost:4200/#/product/add. After published in my domain it works properly but while refresh the page it shows 404 error because of # in my url. Is it possible to do this?

  • Need to remove # in url
like image 871
perumal N Avatar asked Dec 06 '18 12:12

perumal N


People also ask

How do you know if a tick head is still in you?

How to tell if you got the tick head out? You might have gotten the whole tick with your first attempt at removing it. If you can stomach it, look at the tick to see if it's moving its legs. If it is, the tick's head is still attached and you got the whole thing out.

How do you remove a tick with Vaseline?

Do not try to kill, smother, or lubricate the tick with oil, alcohol, petroleum jelly, or similar material while the tick is still embedded in the skin.

How long does a tick stay on you?

If you don't find the tick and remove it first, it will fall off on its own once it is full. This usually happens after a few days, but it can sometimes take up to two weeks. Like when you have a mosquito bite, your skin will usually become red and itchy near the tick bite.


1 Answers

You need to change your LocationStrategy to PathLocationStrategy

By default angular use the PathLocationStrategy, that said looks like you're probably defining HashLocationStrategy yourself. Look for some sort of this code in your project:

RouterModule.forRoot(routes, { useHash: true })

In this case just remove the useHash like so:

RouterModule.forRoot(routes)

Or maybe

[Location, {provide: LocationStrategy, useClass: HashLocationStrategy}]

In this case change HashLocationStrategy to PathLocationStrategy like so:

[Location, {provide: LocationStrategy, useClass: PathLocationStrategy}]
like image 162
benshabatnoam Avatar answered Oct 02 '22 15:10

benshabatnoam