Solved

Redirect folder content to CDN using mod_rewrite

Posted on 2010-08-22
3
851 Views
Last Modified: 2012-05-10
I would like to redirect content that is placed onto our CDN using mod_rewrite. The following rule is not working correctly. I only want content in a specified folder to redirect and not the root or entire domain.

RewriteCond %{REQUEST_URI} !^/dl/$
RewriteRule ^(.*)$ http://c0002.cdn1.cloudfiles.rackspacecloud.com/$1 [R=302,L]

Open in new window


This tries to use the CDN for every file requested and not just the files that would appear to come from the dl folder which is not desirable. Also when going to www.domain.com/dl/file.zip I am redirected to http://c0002.cdn1.cloudfiles.rackspacecloud.com//dl/file.zip, notice the addition of the /dl/

Here is the example I was following: http://se.id.au/journal/files/mosso_cloudfiles_with_own_domain.php
0
Comment
Question by:adamshields
  • 2
3 Comments
 
LVL 4

Expert Comment

by:Frozenice
ID: 33496304
ok..

on your script above..

try putting on top line






RewriteEngine On

Open in new window

0
 
LVL 3

Author Comment

by:adamshields
ID: 33496495
It's already on, just didn't include it.
0
 
LVL 3

Accepted Solution

by:
adamshields earned 0 total points
ID: 33498104
I got it to work with just the following rule.

RewriteRule ^/dl/(.*)$ http://c0002.cdn1.cloudfiles.rackspacecloud.com/$1 [R=302,L]

Though I'm still wondering why the first two rules did not?
0

Featured Post

Scale it in WD Gold

With up to ten times the workload capacity of desktop drives, WD Gold hard drives employ advanced technology to deliver among the best in reliability, capacity, power efficiency and performance.

Join & Write a Comment

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
This article will show, step by step, how to integrate R code into a R Sweave document
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now