Redirect URLs with #! dynamic content

2019-08-18 02:00发布

问题:

I had a temporary site made on Wix, and will soon need to move to a new one made in Zend Framework 2. For SEO reasons, not to lose the ranking gained so far, I need to 301 redirect the page URLs of the old site to pages in the new one, the problem is that Wix uses some weird addresses like www.mysite.com/#!about/etc, so the Redirect 301 rule in .htaccess doesn't work as the stuff after the # is not seen as a part of the link. How can I redirect from such URLs without losing their Google juice? Thanks.

回答1:

This code should allow you to transfer the parameters to the final site with a 301.

RewriteEngine On

RewriteCond %{HTTP_HOST} ^yourdomain.tld [NC]
RewriteRule ^(.*)$ http://newdomain.tld/$1 [R=301,L]


回答2:

After some more research, I found out Wix is using Ajax crawling, which is really unfriendly when you need to move away and redirect your pages, as it uses #! in the URLs. I also found out that those URLs get parsed by Google as escaped fragments, so I used

RewriteCond %{QUERY_STRING} ^_escaped_fragment_=about/etc$
RewriteRule ^$ /about? [R=301,L]

Hope that does the job and redirects my old pages' Google juice to the new ones.