Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Thanked 0 Times in 0 Posts

    RewriteRule - Multiple domains with shared folder

    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]
    Last edited by devmond; 08-20-2008 at 04:20 AM. Reason: better wording


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts