Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialsourav Roy
Courses Plus Student 40 PointsAngularJS remove # and have error when refresh page
Reloading the page or manually type URL like "localhost/mysite.com/contact" gives wrong "Not Found"(404 error) on the server. This is because MVC does not know about angular routing and by MVC pattern it will look for an MVC page for 'contact' which does not exist in MVC routing path. I think there is a solution by .haccess file by redirect all links to the index page, but it, not a good idea.
I already add a baseURL constant to the application in head. and the js part is below:
app.config(function($routeProvider,$locationProvider) {
$routeProvider.
when("/contact", {
templateUrl : "partial/contact.html"
}).
when("/aboutus", {
templateUrl : "aboutus.html"
}).
when("/service", {
templateUrl : "service.html"
}).
otherwise({
redrictTo: "index.html"
})
$locationProvider.html5Mode(true);
});
How can I fix the issue angular to get the correct page (localhost/mysite.com/contact) when I go to the contact page by typing URL manually.
1 Answer
tjgrist
6,553 PointsHave you tried not including the mysite.com bit in the URL? So, having: localhost:####/contact