Beware the Evil Facebook Query

Like a car going off a cliff, the Facebook fragment can lead your users on a short trip to nowhere.Jeff Stevens recently discovered an odd Internet Explorer / Facebook “Like” bug that appended “?fb_xd_fragment=” to the end of shared articles on someone’s Facebook wall.

The problem was, when links containing that fragment were used, the website would not show anything – zip, zilch, nada – completely blank.

In checking our Google Analytics, we saw ample traffic pointing to users viewing content on our websites with this fragment in the URL.

Solution: .htaccess to the Rescue

Some solutions suggested using javascript to solve the redirect issue, but we like another method: .htaccess.

Since users are visiting your website via a specific URL, you should be able redirect them based on that fact, well before any PHP or Javascript is loaded.

To accomplish this, insert the following 2 lines into your .htaccess file

RewriteCond %{QUERY_STRING} fb_xd_fragment=
RewriteRule (.*) $1? [R=301,NC,L]

WordPress MultiSite Implementation

For our WordPress MultiSite service, which we configured as sub-domains, we had to modify the RewriteRule just a bit:

RewriteCond %{QUERY_STRING} fb_xd_fragment=
RewriteRule (.*) http://%{HTTP_HOST}/$1? [R=301,NC,L]

Now the thousands of poor visitors seeing blank websites will be redirected to a normal website.

Photo by Jake Bouma, Flickr.

About the Author


Jeffrey Stevens

Jeff Stevens is the Assistant Web Manager for UF Health Web Services. He focuses on user experience, information architecture, content strategy, and usability.

Read all articles by Jeffrey Stevens