Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am creating a gateway page that redirects visitors based on what services they are using.

How should a .htaccess rule that redirects a visitor if he has a cookie originating from the domain accounts.google.com look like?

RewriteEngine On
RewriteCond %{REQUEST_URI} /ingoing*$
RewriteCond %{HTTP_COOKIE} ?? WHAT SHOULD I PUT HERE ??[NC]
RewriteRule . example.com/outgoing [R,L]
share|improve this question

closed as off-topic by ceejayoz, mdpc, Wesley, Ward, Jenny D Apr 19 at 16:51

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must be relevant to professional system administration. Server Fault is dedicated to professional system and network administrators. End user and enthusiast questions are off-topic (contact your system administrator or hire a professional to help you out). Please see the Help Center for more information." – mdpc, Wesley, Ward
If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers 2

up vote 9 down vote accepted

You cannot do this because you can only see cookies from the domain that your site is on. The browser will NOT send you any cookies from other domains.

share|improve this answer
    
+1 for nice answer, If browser would allow to read cookies for cross domain then there would be major security problem. :) –  Log1c Apr 19 at 6:19
    
What if I added a Google Maps iframe to my website? When I am logged into Google Maps I see my profile picture on the top right corner of the map, this could work (unless iframes have hidden cookies). –  SkyHiRider Apr 19 at 11:53
    
You will not be able to run your own code in that iframe (if we're talking about JS). You need to read a bit on how the HTTP protocol works. –  Florin Asavoaie Apr 19 at 16:44

In the end you are asking for instructions for session hijacking. There are ways that might work, but once you are detected any search engine will kick your site out of their index as an attack site.

Though there is a simple solution: If you want to know if the new user found your site through Google or another search engine check the referer. Since you are using mod_rewrite search the Apache Docs for HTTP_REFERER.

share|improve this answer
    
I want to create a gateway page - if the user is logged into Google I want him to be redirected to the Google Review page, otherwise he should be redirected to a general review page. –  SkyHiRider Apr 18 at 21:01
1  
As Florin Asavoaie pointed out: no legal way to get that cookie. –  Rüdiger Voigt Apr 18 at 21:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.