最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Angular: 404 page but keep url - Stack Overflow

programmeradmin3浏览0评论

I wrote a custom 404 page in Angular 4 and want to keep the wrong url that was entered. You can see the behavior on github for example. They display a 404 page for not existing urls. Example:

Currently I configured my router like this:

{ path: '404', ponent: NotFoundComponent },
{ path: '**', redirectTo: '404' }

Any idea how to archive this?

I wrote a custom 404 page in Angular 4 and want to keep the wrong url that was entered. You can see the behavior on github for example. They display a 404 page for not existing urls. Example: https://github./cdkdfjkdjf

Currently I configured my router like this:

{ path: '404', ponent: NotFoundComponent },
{ path: '**', redirectTo: '404' }

Any idea how to archive this?

Share Improve this question edited Aug 30, 2017 at 18:42 Lazar Ljubenović 19.8k10 gold badges58 silver badges95 bronze badges asked Aug 30, 2017 at 17:12 netshark1000netshark1000 7,41311 gold badges65 silver badges122 bronze badges 2
  • Check this answer: stackoverflow./questions/36260839/… – Sergio Escudero Commented Aug 30, 2017 at 17:23
  • Possible duplicate of Angular 2 How to redirect to 404 or other path if the path does not exist – Kyle Krzeski Commented Aug 30, 2017 at 18:36
Add a ment  | 

1 Answer 1

Reset to default 12

The solution is very simple:

 { path: '**', ponent: NotFoundComponent }
发布评论

评论列表(0)

  1. 暂无评论