Step 3: Configuring Apache
Now, the remaining step is to configure apache to rewrite this URL:
http://www.domain2.com/-66543afe6543asdf6asd-/contact/
…to this:
http://www.domain2.com/contact/?sessionid=66543afe6543asdf6asd
…and this kind of url:
http://www.domain2.com/-66543afe6543asdf6asd-/contact/?email=yes
…to this:
http://www.domain2.com/contact/?email=yes&sessionid=66543afe6543asdf6asd
To achieve this, simply configure your two virtual servers for domain1 and domain2 as
follows:
follows:
<VirtualHost ipaddress> DocumentRoot /usr/local/www/domain1 ServerName www.domain1.com RewriteEngine on RewriteRule ^/-(.*)-(.*?.*)$ $2&sessionid=$1 [L,R,QSA] RewriteRule ^/-(.*)-(.*)$ $2?sessionid=$1 [L,R,QSA] </VirtualHost> <VirtualHost ipaddress> DocumentRoot /usr/local/www/domain2 ServerName www.domain2.com RewriteEngine on RewriteRule ^/-(.*)-(.*?.*)$ $2&sessionid=$1 [L,R,QSA] RewriteRule ^/-(.*)-(.*)$ $2?sessionid=$1 [L,R,QSA] </VirtualHost>
Those rewriting rules implement the above two URL rewriting requirements.
Conclusion
By using the combination of variables and apache rewriting, cross-domain cookies can
be implemented in a simple fashion. In order to maintain the system, your coders
need to do nothing more than use the domain variables whenever they link across domains.
Links within domains do not need to be modified, as the cookie will work properly.
be implemented in a simple fashion. In order to maintain the system, your coders
need to do nothing more than use the domain variables whenever they link across domains.
Links within domains do not need to be modified, as the cookie will work properly.
If you are interested in seeing this system in action on a production network, please
visit http://www.familyhealth.com.au/. Run
your mouse over some of the inter-domain links and see how they are rewritten when you
click on them.
visit http://www.familyhealth.com.au/. Run
your mouse over some of the inter-domain links and see how they are rewritten when you
click on them.
Perhaps, the only problem with this technique is that it is impossible to delete the
cookie in the users browser for all the domains.
cookie in the users browser for all the domains.
— Chris