0

I have several blogs. I also have a wordpress blog , which is the main one.

I am driving traffic from the blogspot to the main wordpress blog. I want to display content or links based on from which url a user is coming from.

For example.

If a user is coming from www.anyname.com/mobile I want to show mobile phone related conetnts.

If a user is coming from www.anydomian.com/laptops I want to shows laptop related contents.

So - how to detect from which url a user is coming from ? I have tried the "HTTP_REFERER" code , it shows only current url.

Shijil T
  • 49
  • 1
  • 9
  • I would make dynamic webpages rather than hard coded urls. then you can use ?action=mobile and easily pull all mobile related content this way. Otherwise use pregmatch on the url to get everything after .com/ – Matt Apr 27 '16 at 14:47
  • @Matt , But so far I am not even able to detect the link. Tried some HTTP_REFERER scripts , it shows no source url as result!!! – Shijil T Apr 27 '16 at 14:50
  • Have you tried SERVER commands like `$_SERVER['REQUEST_URI'];`? – Matt Apr 27 '16 at 14:51
  • Look at http://stackoverflow.com/questions/6768793/get-the-full-url-in-php/8891890#8891890 for more info on getting the url – Matt Apr 27 '16 at 14:52
  • @Matt , the script work when I send hits within the domain , but why its not detecting Goo.gl links ? – Shijil T Apr 27 '16 at 14:54
  • You could use a query string when linking between the sites? `another-domain.com?source=anydomian.com/laptops`... HTTP_REFERER would have been a good candidate if it wasn't for the fact that a lot of routers strips that header, as a privacy feature. Poorly configured redirects in between might lose that header, as well. – M. Eriksson Apr 27 '16 at 15:16

1 Answers1

0

You can use: Mobile Detect

So if it is mobile you redirect them to any URL you want, if it's not then stay on the page

Spiro
  • 21
  • 2