Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is it possible the following scenario: I want to access a third-party site through my web server. Is it possible in the middle to rewrite all request to the third party .CSS files to files on my server?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Yes, though it will be YOUR web-server doing the fetching not the client. Doing so in a badly configured way opens you up to being an open-proxy on the net which is a Bad Thing. Unless you have SSL considerations, you'll probably get better client-side parallelization by calling the css files directly on the remote server from your own pages.

<ifModule mod_proxy.c>
    RewriteRule http://example.com/css/pretty.css    http://othersite.com/css/pretty.css [P]
</ifModule>

This will leverage mod_rewrite and mod_proxy to do exactly what you want, requests for pretty.css on your site will be fetched from the remote site and served as if it were yours.

Where you can get into trouble is when you start introducing regexes into the RewriteRule.

<ifModule mod_proxy.c>
    RewriteRule http://example.com/css/(+*)    http://othersite.com/css/$1 [P]
</ifModule>

This will pass anything like http://example.com/css/../cgi-bin/mt.cfg to the remote site, and the remote site will serve it up just fine.

share|improve this answer
    
I think he actually means rewrite the content within the requests? –  Sargun Dhillon Dec 27 '10 at 21:18
    
@Sargun Even easier, just change the [P] to [R] and remove the ifModules, and that'll do exactly that. And safely! –  sysadmin1138 Dec 27 '10 at 21:21
    
10x for the help, this is exactly what I was looking for. –  bozhidarc Dec 29 '10 at 11:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.