...

View Full Version : RewriteRule - Multiple domains with shared folder



devmond
08-20-2008, 03:14 AM
I have been having major problems trying to have both of my sites then share the same image folder (as there are many images common for both) for one of the domains created as below.
My images folder is called 'imgs' and sits in the initial domain folder '/firstdomain/imgs'. Now I want the second domain to use the first domains images folder (seconddomain/imgs = firstdomain/imgs).

As there may be other domains on the same server I wish to have only the seconddomain use the images folder, so have added the RewriteCond in my attempted solution methods.

Think i must be close, but just can't get it to work from a number of varying scripts below (which are added below the initial setup for the domains - also tried adding variations above)

Please post a tested solution as I would have thought a number of my attempts should have worked!

----------------------------------------------------
two domains served from one root
this works initial part works fine
----------------------------------------------------
RewriteCond %{HTTP_HOST} firstdomain.com
RewriteCond %{REQUEST_URI} !^/firstdomain
RewriteRule ^(.*)$ firstdomain/$1 [L]

RewriteCond %{HTTP_HOST} seconddomain.net
RewriteCond %{REQUEST_URI} !^/seconddomain
RewriteRule ^(.*)$ seconddomain/$1 [L]

----------------------------------------------------
Some of the scripting I have tried without success
(these where tried below the above script)
----------------------------------------------------
RewriteCond %{HTTP_HOST} seconddomain.net
RewriteRule ^imgs/([^/\.]+)/?$ /firstdomain/imgs/$1 [L]
#
RewriteRule ^seconddomain/imgs/([^/\.]+)/?$ /firstdomain/imgs/$1 [L]
#
RewriteCond %{HTTP_HOST} seconddomain.net
RewriteRule ^imgs/([^/\.]+)/?$ http://www.firstdomain.com/imgs/$1 [L]
#
RewriteRule ^http://www.seconddomain.net/imgs/([^/\.]+)/?$ http://www.firstdomain.com/imgs/$1 [L]
#
RewriteCond %{HTTP_HOST} seconddomain.net
RewriteRule ^imgs/([^/\.]+)/?$ /root/path/to/firstdomain/imgs/$1 [L]



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum