I was advised to post here from Stack Overflow
We need help. We're running an ad campaign and realized that a lot of paid traffic was landing on a 404 not found page.
The issue is caused by auto-tagging in Google Ads when it appends a gclid parameter to the query string. Google Ads has the option to disable auto-tagging but there is no such option in Facebook. Traffic from Facebook lands on a 404 not found page every time. We inherited the site that was built on Joomla 3.10.0
Here's what happens:
- We specify the link we want to promote, e.g. https://www.example.com
- Google & Facebook append their parameters, e.g. ?fbclid=IwAR1m3AFCDb2Ouiickaw3lk4CqMCbfgf0wc-JX-08WTddIw0CCw7iyCoLs2g
Then, something weird happens with the redirection. The server access logs show the request getting redirected from:
https://www.example.com/?fbclid=IwAR1m3AFCDb2Ouiickaw3lk4CqMCbfgf0wc-JX-08WTddIw0CCw7iyCoLs2g
to
https://www.example.com/www.example.com/?fbclid=IwAR1m3AFCDb2Ouiickaw3lk4CqMCbfgf0wc-JX-08WTddIw0CCw7iyCoLs2g
NOTE: example.com/www.example.com/
to
https://www.example.com/page-not-found
We think it's related to Joomla's rewriting system but aren't familiar with it enough to know how to fix it. It's also possible that we have a misconfiguration in the .htaccess file.
We have Search Engine Friendly URLs enabled. We have Use URL Rewriting enabled.
The site is in the /public_html/ folder. We've tried commenting out different parts of the .htaccess but nothing worked. We normally use WordPress and have limited knowledge of Joomla and/or .htaccess files.
One final note: normal, readable query parameters don't seem to cause this issue because our manual UTMs work fine. Something about the fbclid/gclid strings in particular may be related... that's just a guess.
Here's a copy of our .htaccess:
##
# @package Joomla
# @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
# @license GNU General Public License version 2 or later; see LICENSE.txt
##
## No directory listings
<IfModule mod_autoindex.c>
IndexIgnore *
</IfModule>
## Suppress mime type detection in browsers for unknown types
<IfModule mod_headers.c>
Header always set X-Content-Type-Options "nosniff"
##
# Disable Federated Learning of Cohorts (FLoC)
# If you uncomment the below directive you have to allow this technology in the
# Global Configuration of Joomla. Read more about this in the Post-Installation
# message in the backend.
##
# Header always set Permissions-Policy "interest-cohort=()"
</IfModule>
Options +FollowSymlinks
Options -Indexes
## Disable inline JavaScript when directly opening SVG files or embedding them with the object-tag
<FilesMatch "\.svg$">
<IfModule mod_headers.c>
Header always set Content-Security-Policy "script-src 'none'"
</IfModule>
</FilesMatch>
RewriteEngine On
## Begin - Rewrite rules to block out some common exploits.
# Block any script trying to base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
# Block any script trying to set a PHP GLOBALS variable via URL.
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block any script trying to modify a _REQUEST variable via URL.
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Return 403 Forbidden header and show the content of the root home page
RewriteRule .* index.php [F]
## End - Rewrite rules to block out some common exploits.
## Begin - Custom redirects
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
## End - Custom redirects
##
# Uncomment the following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root).
##
RewriteBase /
## Begin - Joomla! core SEF Section.
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
## End - Joomla! core SEF Section.
Thanks for any insight you can provide.