using mod-rewrite to redirect requests for jquery.js to GoogleAPI cache

Posted by Aditya Advani on Stack Overflow See other posts from Stack Overflow or by Aditya Advani
Published on 2010-05-18T07:49:33Z Indexed on 2010/05/18 7:50 UTC
Read the original article Hit count: 281

Filed under:
|
|
|
|

Hi All,

Our Linux server with Apache 2.x, Plesk 8.x hosts a number of e-commerce websites. To take advantage of browser caching we would like to use Google's provided copy of jquery.js.

Hence in the vhost.conf file of each we can use the following RewriteRule

RewriteCond %{REQUEST_FILENAME} jquery.min.js [nc]
RewriteRule . http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js [L]

And in vhost_ssl.conf

RewriteCond %{REQUEST_FILENAME} jquery.min.js [nc]
RewriteRule . https://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js [L]

OK now these rules work fine in the individual vhost.conf files of each domain. However we host over 200 domains, I would like for them to work but cannot seem to get them to work globally in the httpd.conf file.

Challenges are the following:

  1. Get the rewriterule to work in httpd.conf
  2. Detect if HTTPS is on, and if it is and the is is a secure page, rewrite to ...
  3. Each individual domain will still have it's own custom mod-rewrite rules. Which rules take precedence - global or per-domain? Do they combine? Is it ok if I have the "RewriteEngine On" directive in the global httpd.conf and then again in the vhost.conf?

Please let me know what your guys' suggestions are. Desperate for a solution to this problem.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about mod-rewrite