Mapping content over domains with Apache
Posted by primeminister | Filed under Cake-Toppings, Other (tech) stuff
Using ‘Dynamic Mirror‘ in Apache you can map content from one domain to another. This was useful for a customer who had two very old domains from 1993 and built-up a nice SEO ranking.
We have two domains a-domain.com and b-example.com. The last one has a new design and some different links and is an application built in CakePHP.
The other domain ‘a-domain.com’ had its purpose to serve the same content.
Why not just 301 redirects?
Because my client didn’t want to take the risk to loose search engine ranking right now. Maybe we will serve the 301 at a later stage, as in my opinion it is the best honest way to deliver the content.
So without redirects you can use the Proxy Throughput feature (flag: [P]).
…we want a dynamic mirror with data which gets updated automatically when there is need (updated data on the remote host).
So the content will map through a sort of reversed proxy to the second domain. Here is how I did it:
RewriteEngine On # map everything that is not a file or dir in the a-domain webroot to example-b.com # http://httpd.apache.org/docs/2.0/misc/rewriteguide.html # search for 'Dynamic Mirror' RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{HTTP_HOST} ^.*\.a-domain\.com(/.*)? [NC] RewriteRule ^(.*)$ http://www.example-b.com/$1 [P,L]
Any questions or remarks? Just leave a comment.