Question:

What ruleset should i perform the following redirects:

[1] http://www.xyzblog.com/foo/bar.php  => htdocs/projects/xyzblog/foo/bar.php
[2] http://www.xyzblog.com/js/jquery-min.js => htdocs/js/jquery-min.js

[3] http://www.bigcommerce.ch/images/baz.png => htdocs/projects/bigcommerce/images/baz.png
[4] http://www.bigcommerce.ch/css/reset.css => htdocs/css/reset.css

In [2] and [4] the asked for file does appear in the initial path, so no redirect happens.

Background:

I've got a WAMP envo which utilizes Apache Friend's excellent XAMPP. Sometimes on multiple projects for various clients and also have setup the next directory structure:

htdocs
  + css
  + images
  + includes
  + js
  + projects
     + bigcommerce
     + xyzblog
     ...

After I start focusing on a brand new project I produce a directory with similar title under projects furthermore, I title the project following the host title from the client. Therefore if I start focusing on a task in which the production site could be http://www.dreamvacation.com I give a dreamvacation directory underneath the projects directory.

Lastly I temporarily, add the next line to my hosts file in C:\WINDOWS\system32\drivers\etc

127.0.0.1   dreamvacation.com

This way all demands to dreamvacation.com could be short circuited to my localhost.

I still need one aspect of have the ability to code on localhost and expect it some thing exactly the same way when submitted towards the production server. That's an htaccess file to check on exactly what the host title is incorporated in the request and redirect to some directory with similar title minus the top domain identifier (.com, .net, etc). The redirection should only occur when the asked for file doesn't exist. This last condition can there be because I place commonly used files in sites under htdocs - for example I have only one jquery-min.js in htdocs/js and just one blueprint css in htdocs/css/blueprint/screen.css. However each project also offers a js, css, ... subdirectory only for project-specific files.

How could this be accomplished?

You need to certainly take a look at named based virtualhosts. Beginning your directory root on each client directory. This is actually the real solution :-)

For the shared folers you could utilize "Alias" instructions during these Virtualhost to ensure that some sites would always concentrate on the same places around the directory tree. and employ links to talk about your shared folders.

Anyway that you can do by yourself way too. It something employed for Mass Virtual Hosting, where writing 1000's of Virtualhosts is really a discomfort, mode_rewrite is a great alternative solution.

To identify exisiting files and sites you should use the RewriteCond directives and stop the spinning when the file is available. After that time the real rewrite you have to reuse the apache variable %{HTTP_HOST}. So, I didn't test drive it but something of that nature ought to be a great beginning point (user RewriteLogLevel and RewriteLog to debug),:

RewriteEngine On
RewriteBase /
RewriteCond   %{REQUEST_FILENAME} !-f
RewriteCond   %{REQUEST_FILENAME} !-d
RewriteCond   %{HTTP_HOST}                 ^www\.[^.]+\.com$
RewriteRule   ^(.+)                        %{HTTP_HOST}$1          [C]
RewriteRule   ^www\.([^.]+)\.com(.*) /htdocs/projects/$1$2

This really is according to apache documentation good examples for username based domain names, you can examine this apache doc page for "Mass Virtual Hosting" for additional particulars, but a few of the example includes file-based rules and inspections that you don't need in your dev env. Remember using VirtualHosts without mod_rewrite is unquestionably simpler but mod_rewrite can perform quite everything if you would like.