1

I created a simple app with Backbone and Marionette. Its working properly, no errors or something like that. But when I saw the URL, it has a hash in front of URL, here's my link

programming/index.html#chart 
programming/index.html#tutorial/3 
programming/index.html#tutorial/6

I want to make it cleaner and more readable, I want remove the hastag and replace by / so the URL looks like this

programming/index.html/chart
programming/index.html/tutorial/3
programming/index.html/tutorial/6

and can access this too

programming/chart
programming/tutorial/3
programming/tutorial/6

I tried much of answer of this question

Routing in Backbone.js / Marionette.js - no hashtags, route list and sub-routers

BackboneJS - Router issues - how to get clean URL's

I tried to make pushState to true, like this

programming.on('start',function(){
    if(Backbone.history){
        Backbone.history.start({
            pushState : true
        });  

        if(this.getCurentRoute() === ""){
            programming.trigger("program:list")
        }
    }
})

I tried to make a .htaccess file

<IfModule mod_rewrite.c>
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)$ /#$1 [R,L,NE]
</IfModule>

But all of them not working for me :( please everybody help me out.

Community
  • 1
  • 1
Engkus Kusnadi
  • 2,386
  • 2
  • 18
  • 40
  • 1
    I do not think you can do this, because if you remove hash then it will go for server side routing not client side routing and you need hash for non HTML5 browsers – nikhil mehta Aug 08 '16 at 05:44

1 Answers1

0

this is working for me.

$('body').delegate('a[href]:not([href^=\#])', 'click', function (e) {
   e.preventDefault();
   Backbone.history.navigate($(this).attr('href'), {trigger: true});
});
V.S.V
  • 302
  • 2
  • 20