Apache .htaccess Rewrite CDN / Parallel Subdomains Drupal CDN

Author:

admin

Created:

2011/11/27 - 00:32

Last Updated:

2011/12/10 - 22:51

First off, I suck at programming... secondly, I suck at apache rewrite rules because it's basically programming. It took me a while to come up with a no-nonsense method to rewrite my parallel / cdn subdomain names, so I wouldn't get hassled by the search engines because it looked like I had all sorts of duplicate content being served from my cdn subdomains.

I say "cdn" subdomains because that's what I searched on forever until I realized I wasn't truly doing content delivery network or content distribution network (CDN), I was simply doing parallel downloads. Yeah, I feel stupid, don't nark on me... :p

The main reason I got so confused is because Drupal has a module called CDN that will do parallel downloads, but it will also do a lot of fun stuff with actual CDN's too.

Moving on, I wanted to share the page that got me started, but also share the RewriteRule I enabled on my site which seems to be working pretty good at this point:

RewriteCond %{HTTP_HOST} ^srv(1|2|3)\.example\.com$ [NC]
RewriteCond %{REQUEST_URI} !\.(css|js|swf|png|gif|jpe?g|pdf|gz|zip)$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R]

srv(1|2|3)\.example.com being:
srv1.example.com
srv2.example.com
srv3.example.com

Post Comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.

Comments

The Wichita Computer Guy is hosted by one of the best hosting companies on the market: Hostgator.com. Not only do they provide unlimited domain addons, subdomains and parked domains, they also offer unlimited databases, unlimited hosting space and unlimited bandwidth! We have been using Hostgator for several years now and had great customer service support and almost 100% uptime. If you are looking for a website hosting company that provides everything you need for a powerful CMS based website, take a look at Hostgator.com!!