Jump to content

PS1.7 getting 404 when opened from Facebook or Google


Recommended Posts

Hey! I'm having a hard time with urls in my prestashop. I have installed multishop, prettyUrls and now I'm facing a big problem. When clicked Google Ad or Facebook link with my website it comes with mydomain.com/index.php?controller=404. I found that Facebook and Google are adding parameters to links, like mydomain.com/?fbclid=123, /?gclid=123.

I worked around this problem with .htaccess:

RewriteBase /
RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)fbclid=(?:[^&]*)((?:&|$).*)$ [NC]
RewriteCond %1%2 (^|&)([^&].*|$)
RewriteRule ^(.*) /$1?%2 [R=301,L]

RewriteBase /
RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)gclid=(?:[^&]*)((?:&|$).*)$ [NC]
RewriteCond %1%2 (^|&)([^&].*|$)
RewriteRule ^(.*) /$1?%2 [R=301,L]

And it is not only those two parameters, any parameter with question mark would lead to 404, like: mydomain.com/?anything

Anyways now Google is crying that my gclid parameter was modified or deleted.
So how to do it right? 

Edited by Smokovsky
added tags (see edit history)
Link to comment
Share on other sites

  • 4 months later...
16 minutes ago, tomasz_be said:

Hello,

This is what I did, but as I still haven't received a reply from the developer I thought that Smokovsky might have the solution.

I can send you a module I'm using on my clients to test it out. Working great. Send me private.

Link to comment
Share on other sites

  • 3 months later...
  • 6 months later...
  • 2 months later...
  • 2 weeks later...
On 6/9/2022 at 4:44 PM, Nickz said:

what is your problem? Many people forget about a trailing slash which could be the culprit of the 404.

Ads pointing to homepage start returning error 404 with no reason.

Link to comment
Share on other sites

No errors on server logs, nothing to do with php version.
The problem was with the gclid param google sets to track the ads campaigns performance.
I updated my htaccess to remove this in order to bypass 404 errors on homepage.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...