Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7554963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:28:35+00:00 2026-05-30T11:28:35+00:00

I have a router that does the site navigation nicely and also works when

  • 0

I have a router that does the site navigation nicely and also works when clicking the browsers back / forward button. However, when entering directly an URL I get 404.

Here is my router:

define(function(require) {
var $         = require('jquery'),
    _         = require('underscore'),
    Backbone  = require('backbone');

var AppRouter = Backbone.Router.extend( {

    routes: {
        'home'       : 'homeHandler',
        'webdesign'  : 'webHandler',
        'mobile'     : 'mobileHandler',
        'javascript' : 'javascriptHandler',
        'hosting'    : 'hostingHandler',
        'contact'    : 'contactHandler'
    },

    initialize: function() {
        this._bindRoutes();
        $('.link').click(function(e){
            e.preventDefault();
            Backbone.history.navigate($(this).attr("href"),true);
        });
        if(history && history.pushState) {
            Backbone.history.start({pushState : true});
            console.log("has pushstate");
        } 
        else {
            Backbone.history.start();
            console.log("no pushstate");
        }
        console.log("Router init with routes:",this.routes);
    },

    homeHandler: function(e) {
        require(['../views/home-content-view', '../views/home-sidebar-view'],
            function(HomeContent, HomeSidebar) {
                var homeContent = new HomeContent();
                homeContent.render();
                var homeSidebar = new HomeSidebar();
                homeSidebar.render();
        });
    },

    webHandler: function(e) {
        require(['../views/web-content-view', '../views/web-sidebar-view'],
            function(WebContent, WebSidebar) {
                var webContent = new WebContent();
                webContent.render();
                var webSidebar = new WebSidebar();
                webSidebar.render();
        });
    },

    ...

});

return AppRouter;
});

Obviously, I’m missing something.

Any clarification would be greatly appreciated.

Thanks,
Stephan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T11:28:36+00:00Added an answer on May 30, 2026 at 11:28 am

    Backbone operates on a web-page (that has already been loaded in the browser). When you enter a URL in the browser directly, you’re making a HTTP-request for that URL to the server. The server is not managed by Backbone. You have to define on the server the behavior when such HTTP-requests are encountered.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have a route that looks something like: www.abc.com/companyName/Controller/Action/Id However, all the
I have a site that treats / and %2F in the path portion (not
I currently have an ASP .NET MVC site that has two domains pointing to
Does anyone have some code that will determine if an IP address (IPv4 or
I have an ASP.NET 4.0 WebForms site that is running on a IIS6/Server 2003
I have a certain part of my site that checks if the logged on
I have a route that I am calling through a RedirectToRoute like this: return
I made a custom handler that derives from MvcHandler. I have my routes using
All, my situation is that I have the basic route, plus some other simple
I have decided that all my WPF pages need to register a routed event.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.