I am trying to redirect all the users they are not being redirected from Facebook Ad to a regular static page instead of an Landing Page. The Landing Page should be visible just to the users they access it through a Facebook ad. If they are trying to access this landing page with direct URL or coming from different sources than they should be redirected to a different static page. Can be done just with javascript? and without modifying the .htaccess?
Asked
Active
Viewed 46 times
0
-
Maybe you can take a look at the `referer` HTTP header? It should contain the domain which referred you to the landing page. – Fjarlaegur Jan 16 '18 at 11:30
3 Answers
0
You could try to read out document.referrer
in js and act accordingly (https://developer.mozilla.org/en-US/docs/Web/API/Document/referrer)
This should contain the page the user is comming from!
Also see here: How to get HTTP-Referer via JS | Jquery?

FMK
- 1,062
- 1
- 14
- 25
0
You may also take a look into the Referer
HTTP Header to perform the redirection on the server side: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer

Gildas
- 1,158
- 1
- 10
- 25
-
Ok perfect, i took a look to the Referer and it is exactly wahat i was looking for. Thank you all and Regards – Alex Scha Jan 16 '18 at 12:04
0
One of the way to check where the request is coming from is: $_SERVER['HTTP_REFERER']
. But According to the official PHP documentation:
"This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted".

Harsh Patel
- 6,334
- 10
- 40
- 73

Yojan
- 159
- 1
- 10