views:

103

answers:

1

I'm building a symfony application thats made to run many sites. Similar to this article.

So far so good except he uses some .htaccess "voodoo". To make it so image and css file links get rewriten so to point to a assets directory named after the current domain. Again read the article above if that doesn't make sense.

Here is the line from the article:

RewriteCond /home/ash/projects/carshop/trunk/web/perhost/%{HTTP_HOST}%{REQUEST_FILENAME} -f
RewriteRule (.*) /perhost/%{HTTP_HOST}/$1 [L]

Here is the same line adapted for my Windows testing server:

RewriteCond C:/xampp/projects/listing/web/sites/%{HTTP_HOST}%{REQUEST_FILENAME} -f
RewriteRule (.*) /sites/%{HTTP_HOST}/$1 [L]

Is there something wrong with my syntax or am I not understanding what this .htaccess code is supposed to do. I've checked and mod_rewrite is on.

What I'm trying to do is make it so I don't have to query the database (to retrieve the current website) in order to get the correct path to the files. Each domain would have its images,css, files in its own directory wich is named after itself.

like this

web/sites/website1.com/{images,js,css}

web/sites/website2.com/{images,js,css}

Let me know if you need more info.

Thanks!

A: 

REQUEST_FILENAME already is an absolute filesystem path:

REQUEST_FILENAME
The full local filesystem path to the file or script matching the request.

But why don’t you use $1 in the condition too as that’s also the destination you want to redirect to:

RewriteCond /home/ash/projects/carshop/trunk/web/perhost/%{HTTP_HOST}/$1 -f
RewriteRule (.*) /perhost/%{HTTP_HOST}/$1 [L]
Gumbo