Crawlable AJAX with _escaped_fragment_ in htaccess

后端 未结 5 635
情深已故
情深已故 2021-01-02 19:45

Hello fellow developers!

We are almost finished with developing first phase of our ajax web app. In our app we are using hash fragments like:

http://         


        
5条回答
  •  不知归路
    2021-01-02 20:32

    Here is a solution that provides a routable URL and query parameters correctly set for processing in the server side script.

    Example: If you want http://yoursite.com/#!/product/20 to become http://yoursite.com/crawler/product/20

    First in .htaccess

    RewriteCond %{QUERY_STRING} ^_escaped_fragment_=(.*)$
    RewriteRule ^$ /crawler/index.php?_frag=%1  [L]
    

    We need to get rid of the _escaped_fragment_ in the URL and replace it with something different, example: _frag so that the (Apache) web server does not get in to circular rewrites.

    Second in crawler/index.php

提交回复
热议问题