'DeIndex a URL with a version ending in a hash bang

I just want to deindex or remove the page ending with #!. It is a dynamic page which fetching data from database and rendering on two URLs

  • example.com/detail/297#!
  • example.com/detail/297


Solution 1:[1]

If you want to deindex both of those URLs you should return a "410 Gone" HTTP status for them. (Or even a "404 Not Found" status would work but it isn't as descriptive.)

If you want to deindex only the version with the hash bang, that is a little harder. URLs with the hash, share the same HTTP request, response, and status code as the version without the hash. That means that handling the hash portion of the URL can only be done with JavaScript. You will need to insert JavaScript into the page that detects that presence of the hash bang and implements one of the following:

  • Changes the location.href to remove the hash bang
  • Changes the location.href to the URL of a "410 Gone" error page
  • Dynamically inserts a <meta name="robots" content="noindex"> tag into the <head> of the page.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Stephen Ostermiller