Use a Backbone Router to Work with Hashbang to Index SEO Content?

My SPA uses the Backbone.js router, which uses pushstate and hashed URLs as a fallback method. I intend to use the Google proposal to create an AJAX scanned web application . That is, I want to index my site into static .html files created by PhantomJS and deliver them to Google at the URL:

mysite.com/?_escaped_fragment_=key=value.

Keep in mind that the site does not serve static pages for end users (it only works with a browser that supports Javascript). If you go to mysite.com/some/url, the .htaccess file is set to always serve mysite.com/index.php, and the main router will read the URL to display the content generated by JavaScript for that URL.

Also, for Google to index my entire site, I plan to create a sitemap that will list hashbang URLs . URLs must be marked so that Google knows to index the site using the _escaped_fragment_key URL .

Soooo ...

(1) Will this approach work?

and

(2) backbone.js URL- hashbang, URL- hashbang URL- pushstate, Google?

: qaru.site/questions/46615/...

+4
2

, . ...

(1) , , , . , , , sitemap.xml URL- hashbang. , Google , URL- _escaped_fragment_. , Google, URL- -, .

(2) , . Backbone.js ...

window.location.hash = window.location.hash.replace(/#!/, '#');

var AppRouter = Backbone.Router.extend({...

, - , , pushState. , URL , , "", / .

:

, , . BromBone:

URL- hashbangs (#!), Google , #! ? escaped_fragment =. ? escaped_fragment =, , . html5 pushState, "UserAgent" , .

BromBone, .htaccess: :

    RewriteEngine On
    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{HTTP_USER_AGENT} .*Googlebot.* [OR]
    RewriteCond %{HTTP_USER_AGENT} .*Bingbot.* [OR]
    RewriteCond %{HTTP_USER_AGENT} .*Baiduspider.* [OR]
    RewriteCond %{HTTP_USER_AGENT} .*iaskspider.*
    RewriteRule ^(.*)$ snapshot.php/$1 [L]
+3

, 10 SPA. Google . , SPA. .

, http://vimeo.com/channels/smashingconf.

, , script :

<script>

    if (!('querySelector' in document)
         || !('localStorage' in window)
         || !('addEventListener' in window)
        || !('matchMedia' in window)) {

        if (window.location.href.indexOf("#!") > 0) {
            window.location.href = window.location.href.replace("#!", "?_escaped_fragment_=");
        } else {
            if (window.location.href.indexOf("?_escaped_fragment_=") < 0) {
                window.location.href = window.location.href + "?_escaped_fragment_=";
            }
        }

    } else {

        if (window.location.href.indexOf("?_escaped_fragment_=") >= 0) {
            window.location.href = window.location.href.replace("?_escaped_fragment_=", "#!");
        }
    }

</script>

- _escape_fragment_ querystring. , . CSS JavaScript. SPAHelper ASP.NET MVC, , , , https://github.com/docluv/spahelper.

, -, ASP.NET, PHP .., . , , . 10 , .

+1

All Articles