When using a page with pushState
enabled, the typical method of redirecting SEO bots involves utilizing the escaped_fragment
convention. More information on this can be found here.
This convention operates under the assumption that a hashbang prefix (#!
) will be used before all URIs in a single-page application. SEO bots will then replace this hashbang with their own recognizable convention - escaped_fragment
- when requesting a page.
//Your page
http://example.com/#!home
//Requested by bots as
http://example.com/?_escaped_fragment=home
This approach enables site administrators to identify bots and direct them to cached prerendered pages.
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=(.*)$
RewriteRule ^(.*)$ https://s3.amazonaws.com/mybucket/$1 [P,QSA,L]
The issue arises from the fact that the hashbang is becoming outdated with the widespread use of pushState
support. This method is not only unappealing but also lacks user intuitiveness.
So, what if we transitioned to HTML5 mode where pushState governs the entire user application?
//Your index is using pushState
http://example.com/
//Your category is using pushState (non-folder)
http://example.com/category
//Your category/subcategory is using pushState
http://example.com/category/subcategory
Can rewrite rules still lead bots to the cached version using this newer approach? A related inquiry focusing on the index edge case. Google also offers guidance through an article suggesting an opt-in technique for this singular instance using
<meta name="fragment" content="!">
in the <head>
section of the page. Here, however, we are exploring how to handle every page as an opt-in scenario.
http://example.com/?escaped_fragment=
http://example.com/category?escaped_fragment=
http://example.com/category/subcategory?escaped_fragment=
I propose that the escaped_fragment
could continue to serve as an identifier for SEO bots, allowing me to extract the section between the domain and this identifier to append it to my bucket location like so:
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=$
# (basic example, further implementation required)
# extract "category/subcategory" == $2
# from http://example.com/category/subcategory?escaped_fragment=
RewriteRule ^(.*)$ https://s3.amazonaws.com/mybucket/$2 [P,QSA,L]
What would be the most effective approach to address this situation?