2

I have multiple domains directed to folder with .htaccess my htaccess looks like this:

RewriteEngine On

rewritecond %{http_host} ^domain-2.com
rewriteRule ^(.*) https://domain-1.com/?utm_source=redirects&utm_medium=domain-2.com&utm_campaign=301 [R=301,L]

rewritecond %{http_host} ^domain-3.com
rewriteRule ^(.*) https://domain-1.com/?utm_source=redirects&utm_medium=domain-3.com&utm_campaign=301 [R=301,L]

And I want do this more effective and elegantly - all domains are redirected to domain-1.com

Exist any way how use {HTTP_HOST} or something similar at URL parameters?

1 Answers1

1

Try:

RewriteEngine On
RewriteCond %{HTTP_HOST} !domain-1\.com$ [NC]
RewriteRule ^(.*)$ https://domain-1.com/?utm_source=redirects&utm_medium=%{HTTP_HOST}&utm_campaign=301 [R=301,L]
Jon Lin
  • 142,182
  • 29
  • 220
  • 220