Jump to content

multple domains with shared common folder - RewriteRule


devmond

Recommended Posts

I have been having endless 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 ReWrite condition in my attempted 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]

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.