Google Search: get rid of Hash-Bang indexed pages

423 Views Asked by At

How can I get rid of Hash-Bang indexed pages on Google Search?

In about 2010 I have made a website that used Ajax-loaded content and the use of Hash-Bang in the URLs.

eg: http://example.com/#!98_153

That was the recommended way to get all content crawled by Google in 2010.

12 years later in 2022 a complete relaunch of this Website was done. URLs look (user read-friendly) like
http://example.com/publications/my-first-book now.

There is a robots.txt file. And there is a sitemap.xml. Also there is a Google tag manager on the new site.

Google is still showing those old URLs with Hash-Bangs.

How do I get rid of those Hash-Bangs-Urls?

robots.txt:

Sitemap: https://www.my-websitexxxxx.example/sitemap.xml
User-agent: *
Allow: /
Disallow: /dev/
Disallow: /admin/
Disallow: /Security/
Disallow: /#!*
Disallow: /print/*
1

There are 1 best solutions below

4
Stephen Ostermiller On

The hash and everything after it is client-side only. It isn't part of the URL that is sent to the server. Browsers never send the hash fragment to the server. Crawlers never send the hash fragment to the server. Therefore:

The only thing that you can do is redirect those URLs with JavaScript.

if (location.hash == '#!98_153') location.href = 'http://example.com/publications/my-first-book'

Googlebot now runs JavaScript as part of its crawling process. Once you have the JavaScript redirects in place, Googlebot will eventually find them and honor them. Your hash bang URLs will no longer be indexed.