I want 301 redirect from all pages of SiteA.example
to Home Page of SiteB.example
using .htaccess
rewrite rule, Since I am not PHP guy I am not sure if below rule is correct
RewriteRule ^(.*)$ https://www.SiteB.example/?utm_campaign=domainnames&utm_medium=domain&utm_source=%{HTTP_HOST}" [L,R=301,QSA] [R=301,QSD,L]
I am facing problem since I am not able to track 301 redirects
on SiteB.example
as Google Analytics doesn't track it as this information is not passed on when 301 redirect is taking place.
So rewrite rule was suggested by someone on Stack Overflow but I want to get it right. Can you confirm that the above rewrite rule is fine?
utm_campaign=domainnames&utm_medium=domain&utm_source=%{HTTP_HOST}
for? In the directive you posted you are explicitly preserving the query string from the original request - do you need this? "Since i am not PHP guy" - this has nothing to do with PHP.RewriteRule
directive itself is "OK" (except that you've duplicated the flags argument - which I assume this is just a typo - but this won't actually cause an "error"). But you didn't answer my first question... "Do SiteA and SiteB point to different servers?" If not and SiteA/B is just an alias then the above will naturally result in a redirect loop.Do SiteA and SiteB point to different servers?
Yes both are on different server... I did resolve it by using following as part of query stringhttps://SiteB.com/?utm_campaign=SiteARedirect&utm_medium=301Redirect&utm_source=SiteAWebsite
now i am able to see traffic underTraffic Sources
in Real Time and underAcquisition-->Campaigns-->All Campaigns
before this it was not possible as 301 doesnt often pass this information in header so GA is not able to register it. So this is a way around to track source traffic in this scenarioRewriteRule ^(.*)$ https://SiteB.com/?utm_campaign=SiteARedirect&utm_medium=301Redirect&utm_source=SiteAWebsite [R=301,L]