Solved

Redirect folder content to CDN using mod_rewrite

Posted on 2010-08-22
3
865 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

856 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