301 redirect hashbang (#!) in url

Following on from this topic I created - Will removing #! from the url affect SEO?

I currently have a WIX website. I’m now moving to Wordpress. Before I go live with my new site, I need to redirect all the urls which includes hashbangs (#!) from the old site to the new pretty urls.

Example of old url:

New url:

I’ve tried to do a 301 redirect in htaccess (Redirect 301 /#!about/c2tp /about) but that doesn’t work. I’ve done a lot of research, but nothing seems to be working for me. I’ve heard a few people use sitemap to 301 redirect hashbang url, but I cannot understand how they could do this.

Google has indexed my webpages including the #!. Any suggestions would be appreciated.

I think the part of the url after the hash is not send to the server, so the htaccess redirect won’t work. You could some JavaScript redirect, but it won’t be a permanent solution.

Google use to request urls with hashbang (#!) using the _escaped_fragment_ query parameter. The official post about making ajax request crawable is from 2009. You could check if that is done in your server and do the redirect that way.

1 Like

Thanks @joksnet. After reading the blog post you linked the following should work -

Redirect 301 /?_escaped_fragment_=about/c2tp /about

I’ve added this to my htaccess but after visiting mysite.com/#!about/c2tp but I’m not being redirected?

This is meant for Google indexing only. Sorry for the confusion.

Ok, am I using ?_escaped_fragment_ correctly?

This should tell Google that the page has moved permanently and my pagerank should not be affected, right?

I think. I not very experienced in SEO and Google.

According to https://www.ietf.org/rfc/rfc2396.txt, the # is an illegal (excluded) character in a URI:

2.4.3. Excluded US-ASCII Characters

Although they are disallowed within the URI syntax, we include here a
description of those US-ASCII characters that have been excluded and
the reasons for their exclusion.

delims = “<” | “>” | “#” | “%” | <">

Other characters are excluded because gateways and other transport
agents are known to sometimes modify such characters, or they are
used as delimiters.

4.1. Fragment Identifier

When a URI reference is used to perform a retrieval action on the
identified resource, the optional fragment identifier, separated from
the URI by a crosshatch (“#”) character, consists of additional
reference information to be interpreted by the user agent after the
retrieval action has been successfully completed. As such, it is not
part of a URI, but is often used in conjunction with a URI.

As such, the # is irrelevant to the server and only provides information to the browser (for an anchor within a page).

Learning the correct syntax for URIs is critical for webmasters so take a few minutes to go through that rather lengthy document.



This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.