Apache rewrite based on subdomain

You should have a look at the URL Rewriting Guide from the apache documentation. The following is untested, but it should to the trick: RewriteCond %{HTTP_HOST} ^([^.]+)\.blah\.domain\.com$ RewriteRule ^/(.*)$ http://blah.domain.com/%1/$1 [L,R] This only works if the subdomain contains no dots. Otherwise, you’d have to alter the Regexp in RewriteCond to match any character which should … Read more

Share cookies between subdomain and domain

If you set a cookie like this: Set-Cookie: name=value then the cookie will only apply to the request domain, and will only be sent for requests to the exact same domain, not any other subdomains. (See What is a host only cookie?) Two different domains (e.g. example.com and subdomain.example.com, or sub1.example.com and sub2.example.com) can only … Read more

HTML5 localStorage size limit for subdomains

From http://dev.w3.org/html5/webstorage/#disk-space A mostly arbitrary limit of five megabytes per origin is recommended. Implementation feedback is welcome and will be used to update this suggestion in the future. It also mentions that : User agents should guard against sites storing data under the origins other affiliated sites, e.g. storing up to the limit in a1.example.com, … Read more

Javascript Redirect with Google Analytics

Note: _gaq.push allows pushing of functions onto the queue. The following code should redirect after 250 milliseconds (to allow time for the tracking pixel) after the _trackPageview: var _gaq = _gaq || []; _gaq.push([‘_setAccount’, ‘UA-1234567-8’]); _gaq.push([‘_trackPageview’]); _gaq.push(function() { setTimeout(function() { window.location = “https://market.android.com/developer?pub=Fractal%20Systems”; }, 250); }); (function() { var ga = document.createElement(‘script’); ga.type=”text/javascript”; ga.async = … Read more

When should one use a ‘www’ subdomain?

There are a ton of good reasons to include it, the best of which is here: Yahoo Performance Best Practices Due to the dot rule with cookies, if you don’t have the ‘www.’ then you can’t set two-dot cookies or cross-subdomain cookies a la *.example.com. There are two pertinent impacts. First it means that any … Read more