user1935676
user1935676

Reputation: 55

Redirecting with .htaccess removing query strings

I'm trying to create a facebook like button on a site and when people click on links my wordpress theme doesn't really understand some of facebook complicated query strings and doesn't show anything.

This is the link where "LIKE" button appears:

http://somesite/?p=24

This is how facebook return the link:

http://somesite/?p=24&fb_action_ids=10151164007265846&fb_action_types=og.likes&fb_source=timeline_og&action_object_map={%2210151164007265846%22%3A386632001423999}&action_type_map={%2210151164007265846%22%3A%22og.likes%22}&action_ref_map=[]

I managed to redirect it to my homepage with .htaccess, removing all query strings but I would like to redirect to my actual page, removing only facebook query strings. My code so far:

Options +FollowSymlinks  
RewriteEngine On  
RewriteCond %{QUERY_STRING} fb_action_ids  
RewriteRule ^(.*)$ $1? [R=301]

Upvotes: 2

Views: 982

Answers (1)

Ilmari Karonen
Ilmari Karonen

Reputation: 50328

This should work, assuming that the part of the query string added by Facebook always begins with the fb_action_ids parameter:

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*&)?fb_action_ids=
RewriteRule ^(.*)$ $1?%1 [R=301]

Upvotes: 2

Related Questions