There are two site1.ru site addresses β€” the site2.ru main site. For the second site, DNS addressing is set to the first site.

The question is how to identify users who came from the second site on the first. Htaccess?

Here it is necessary for the first time to come to users from the second site once to display one add. page.

  • write cookies in htaccess or get parameters depending on the domain - splash58

2 answers 2

for example, you can simply redirect all calls to the site2.ru domain name to calls to the additional page of the site1.ru domain. like that:

 rewriteengine on rewritecond %{HTTP_HOST} ^site2.ru [nocase] rewriterule .* http://site1.ru/dopstranica [last,redirect=301] 
  • I tried to do so, but the condition does not catch site2.ru. When you request site2.ru we get the answer: HTTP / 1.1 301 Moved Permanently Location: site1.ru - CaSPeR
  • it should be. only location should be site1.ru/dopstranica . unless, of course, any previously occurring rules interfere. - aleksandr barakin
  • site2.ru/any_url -> site1.ru/any_url and it is required to catch on site1.ru that the request came from site2.ru and to transfer always to site1.ru/dopstranica - CaSPeR
  • @CaSPeR, which, in your understanding, means β€œthe request came from site2.ru (to site1.ru)”, considering that this is the same site? - aleksandr barakin
  • The user in the browser follows the link site2.ru/any_url - CaSPeR

There is a $_SERVER['HTTP_REFERER'] variable to which the name of the site from which the request came is written.

On the site where you need to show an additional page, we write in the .htaccess file

 RewriteEngine On RewriteCond %{HTTP_REFERER} (site2.ru) RewriteRule .* http://site1.ru/dopstranica.html [R=302,L]