.htaccess for SEO bots crawling single page applications without hashbangs

后端 未结 4 1699
后悔当初
后悔当初 2021-01-12 09:21

Using a pushState enabled page, normally you redirect SEO bots using the escaped_fragment convention. You can read more about that here

4条回答
  •  渐次进展
    2021-01-12 10:02

    I was having the exact same problem. For now, I've modified .htaccess like so:

    RewriteCond %{QUERY_STRING} ^_escaped_fragment_=(.*)$
    RewriteRule ^$ /snapshots/index.html? [L,NC]
    RewriteCond %{QUERY_STRING} ^_escaped_fragment_=(.*)$
    RewriteRule ^(.*)$ /snapshots/$1.html? [L,NC]
    

    Not sure if there's a better solution, but it's working for me so far. Just be sure to have the directory structure for your snapshots match the URL structure.

提交回复
热议问题