Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Sun Oct 23, 2011 10:03 am 
Offline
Newbie

Joined: Sat Oct 15, 2011 10:51 am
Posts: 2
Location: London, UK
Hi all

I've set up a CDN for image caching on a web site on my Linode running Lighttpd. I need a redirect rule for the images directory - but RegEx isn't my strong point. I wonder if someone could point me in the right direction?

I'd like to redirect all contents (including one level of nested directories and their contents) in the images directory on the subdomain www to the equivalent on the cdn subdomain - basically:

Redirect: http://www.mydomain.com/images/*

To: http://cdn.mydomain.com/images/*

The format for Lighttpd redirects is:

url.redirect = ( "RegEx" => "redirect_url" )

and I've been playing (unsuccessfully) with something like:

url.redirect = ( "^www.mydomain.com/images/(.*)$" => "http://cdn.mydomain.com/images/$1" )

Any pointers gratefully received.

Thanks


Top
   
 Post subject:
PostPosted: Sun Oct 23, 2011 10:23 am 
Offline
Senior Member

Joined: Sat May 03, 2008 4:01 pm
Posts: 569
Website: http://www.mattnordhoff.com/
Take out the "www.mydomain.com" in that regexp -- literally; remove that, but keep the ^ and / -- and you should be golden. (Obviously, you'll need to put the url.redirect inside the proper vhost instead of making it global.)

_________________
Matt Nordhoff (aka Peng on IRC)


Top
   
 Post subject:
PostPosted: Sun Oct 23, 2011 10:43 am 
Offline
Newbie

Joined: Sat Oct 15, 2011 10:51 am
Posts: 2
Location: London, UK
Brilliant - thank you.

Note: in order to stop a redirect loop I had to redefine the host specific to the subdomain (www) - so my host config looks like this:

$HTTP["host"] =~ "www.mydomain.com" {
server.document-root = "/var/www/mydomain.com/public_html"
server.errorlog = "/var/log/lighttpd/mydomain.com.error.log"
url.redirect = ( "^/images/(.*)$" => "http://cdn.mydomain.com/images/$1" )
}

Thanks again.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group