How to prevent the random 302 redirect imposed by GoDaddy

The “random 302 redirect” that affected this site from Sep 3 to 12 was very disrupting. How does this random 302 redirect work? For example, if a requested URL was, the random 302 redirect would automatically change it to, where XXXXX are five random letters. The number 302 is an HTTP response code that tells the browsers or the search engine crawlers the originally requested URL is “Moved Temporarily”.

§ 1. The problem

When the random 302 redirect was in place, the XXXXX/ string (or directory) was inserted immediately after the domain name (e.g., very frequently (about 2/3 of URL requests). All requested URLs including those of the images, CSS style sheets, and Javascripts, were affected, which rendered my WordPress-powered site broken. 404 Page Not Found errors occurred very often, and I was rarely able to access the dashboard of the website.

At the beginning I thought this was caused by some malfunctioning WordPress plugins, but the random direct still occurred after I disabled all the plugins. After some googling I found this was actually a 302 redirect imposed by name servers. Some more searches like this one seems to indicate that this problem only occurs to GoDaddy domains.

An answer from a GoDaddy staff to the same problem described in this discussion thread clearly showed that GoDaddy does impose such random 302 redirects:

The 302 redirects are filters setup to maintain the integrity of the hosting server. These filters are temporary and will be removed as soon as possible. At this time, you will not need to take action to resolve the issue.Jason (a GoDaddy staff)

It seems that one has to wait for the random 302 redirect to be removed automatically after a couple of weeks. I could not find any real solution that can remove or prevent the random 302 redirect except to transfer the domains away from GoDaddy, which could take more than a week. However, I know that the .htaccess can change or rewrite URL requests easily, so it is possible to use .htaccess to make the web server automatically remove all the XXXXX/ string appended to the domain name.

§ 2. The solution

After skimming through some references on .htaccess [Ref 1],[Ref 2] and regular expressions, I came up with my solution: open the .htaccess file in the root directory of the affected website, copy and Paste the following code at the beginning of the file, and save and upload the edited .htaccess. After doing this, the web server (Apache) will be able to automatically reverse the XXXXX/ random 302 redirects.

RewriteEngine On
RewriteRule ^[a-zA-Z]{5}/(.*)$ $1 [R=301,L]

The above code will work on any URL that contains a XXXXX/ string of lowercase or uppercase letters immediately after the domain name and eliminate the string. For example, will be changed to http://mysite/blog.

One problem is that if your site has actual directories that have five-letter names, the URLs under these directories will be affected by the above rewriting rule. Thus, exceptions have to be made for these specific directories. For example, my site has a five-letter directory, to prevent it from being rewritten to, RewriteCond %{REQUEST_URI} !^/misce/.* was added as shown below.

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/misce/.*
RewriteRule ^[a-zA-Z]{5}/(.*)$ $1 [R=301,L]

3 thoughts on “How to prevent the random 302 redirect imposed by GoDaddy

  1. Pingback: Random 5 alpha character path appended to requests - ExceptionsHub

Leave a Reply