0

As indicated in a similar recent question, in order to have my WordPress blog remove automatically the parameter fbclid=xxxxxxxxx added by FB to all the links pointing to my blog, I inserted the following code to my .htaccess file, in the root of my domain:

RewriteEngine On 
RewriteBase /
RewriteCond %{QUERY_STRING} "fbclid=" [NC]
RewriteRule (.*) /$1? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

The result is that who clicks the link on FB goes to the HOMEPAGE of the blog and NOT to the actual page the linked article is, as desired.

How to resolve this?

Update: I found the solution. I added the following to my htaccess file

<IfModule mod_rewrite.c>
RewriteEngine On 
RewriteBase /
RewriteCond %{QUERY_STRING} ^(.*)&?fbclid=(.*)$ [NC]
RewriteRule ^/?(.*)$ /$1?%1 [R=301,L]
</IfModule>
Konstantinos
  • 11
  • 1
  • 4
  • This doesn’t seem to be the original WP .htaccess file, exception for the `index.php` is missing? https://codex.wordpress.org/htaccess // Anyway, I would rather do this on the client side to begin with (assuming all you want to achieve is that the user doesn’t have to look at this in the address bar?), using the History API replace method … and avoid the external redirect. – misorude Oct 22 '18 at 07:04
  • @misorude Thank you for the suggestion of using the History API replace method. Could you kindly show me which code to include and where in order to achieve the above? – Konstantinos Oct 22 '18 at 12:30
  • @misorude What is the advantage of solving it client-side? I see only disadvantages. We should try to use less JS on our web pages, not more. Making a proper redirection also helps search engines and services like the Wayback Machine understand that the fbclid parameter is not wanted. – clacke Mar 11 '19 at 19:19
  • @clacke that's what you set your `canonical` for correctly in the first place. From a user perspective I would just appreciate one less external redirect, especially with the from social media platform via URL shortener to maybe the intended actual target already, sometime a couple more steps in between ... dance that is daily reality in many cases. A bit of client-side JS cosmetics isn't an issue to me at all here. – misorude Mar 16 '19 at 12:32

0 Answers0