views:

67

answers:

3

Hello

I have a file structure that serves mutliple domains with a top level .htaccess pushing requests down to the domain specific directories:

...

ReWriteCond %{REQUEST_URI} !webroot/domains/www.sitea.com/

ReWriteRule ^(.*)$ webroot/domains/www.sitea.com/$1 [L]

ReWriteCond %{REQUEST_URI} !webroot/domains/www.siteb.com/

ReWriteRule ^(.*)$ webroot/domains/www.siteb.com/$1 [L]

...

An .htaccess at the domain level (e.g. webroot/domains/www.siteb.com/.htaccess) then applies various rules to manage the URLs for the domain pages:

...

DirectoryIndex pageincludes/home.php

RewriteRule ^home$ pageincludes/home.php [L]

...

So the file structure looks something like this :

/webroot/domains/www.sitea.com/

/webroot/domains/www.siteb.com/

/webroot/js/script1.js

/webroot/images/image1.png

My problem is that I want to be able to use common resources in the served pages e.g.:

<script type="text/javascript" src="/js/script1.js"></script> <img src="/images/image1.png" alt="80%"></img>

These resources are not found by the client. Is this pattern a non-starter or is there a way I can get this to work?

Many thanks.

A: 

The way you have it structured now the requests are rewritten so they cannot see the files in the js or images directories.

I'm assuming you want the shared resources to make updates easier, and that's certainly doable (although a better serverfault question). If you place an alias to the directories in your domain folders (and apache is configured to follow aliases) you should be fine.

acrosman
A: 

Could you add an additional condition to each domain, so as not to rewrite requests for these shared resources. e.g.

ReWriteCond %{REQUEST_URI} !^(js|images)

Or how about using a separate domain for the shared resources?

andrewmabbott
+1  A: 

I would just add symbolic links on the file system. Trying to do rewrite rules is kinda complicated and your apache server will have to process them over and over again for every page. Not so for a symbolic link.

Ex:

ln /webroot/js /webroot/domains/www.sitea.com/js

Daniel Ice