0

Is it possible to make such check with htaccess mod_rewrite - If a referer domain is example.com and current host is www.example.com then redirect the user to example.com domain. The meaning is to keep the user at first visiting domain (www or non-www). Thanks!

1 Answers1

0

See, if this works for you.

RewriteEngine on
RewriteBase /

RewriteCond ${HTTP_HOST} ^domain\.com [NC]
RewriteCond ${HTTP_REFERER} ^http://www\.domain\.com
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

RewriteCond ${HTTP_HOST} ^www\.domain\.com [NC]
RewriteCond ${HTTP_REFERER} ^http://domain\.com
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
Ravi K Thapliyal
  • 51,095
  • 9
  • 76
  • 89