configure .htaccess for multisite installation

Hi guys (yeah, I know you missed me...).
I use the multisite (clone zenphoto plugin, yes !) and I have two domain names :
site1.com > main installation
site2.com > cloned installation

The main installation runs fine on site1.com but I don't understand how to configure .htaccess for the cloned gallery in order to use site2.com for it (I hope it's clear).
Any idea ?

Comments

  • acrylian Administrator, Developer
    Actually you don't need to configure anything. Both installs have their own htaccess file and the clone only shares the same base folders via symlinks.
  • flu Member
    Hi Acrylian,
    yes, I realized that but I'd like to use the domain name site2.com for the cloned installation in a "transparent" way.
    To be clearer, I want my .htaccess to replace in the navigation bar http://www.site1.com/site2/ by http://www.site2.com.
    Am I clear ?
  • acrylian Administrator, Developer
    For better overview on the webspace I would recommend this:
    Put both installs in folders /site1 and /site2 on your webspace root and then link the domains to those folders. They are then the "root" for those domains. I am sure your host has something for that on its webspace admin. If not you could redirect via a htaccess in the root to those folders.

    If you have more than one domain each site you need to make one to the main domain ("Duplicated content" avoiding). You then could do that via a htcacess in the root, too.
  • flu Member
    In fact the folders are already set and used like that and I can't change it (for production cause).
    I just need http://www.site1.com/site2/ to be replaced by http://www.site2.com as if it was the root.
    What I am looking for is a way to do this in the .htaccess to get it...
  • acrylian Administrator, Developer
    Well, if you don't want to change it (you really could if you like), you have to redirect the url the same way either using your host's backend or a htaccess redirection. For htaccess redirections there are loads of tutorials on the net.
  • flu Member
    Acrylian, could you tell me what do I have to change in my .htaccess (on site1.com or site2.com) to make it work ?
  • flu Member
    Well, nothing specific to Zenphoto clone option.
    Sorry to have asked.
  • acrylian Administrator, Developer
    No, indeed, just general web stuff ;-) The only part for Zenphoto is that if you redirect a domain to /site2 the ZP htaccess of that has of course needs to be `rewritebase /`. But that is as with root installs since it is then one.
  • flu Member
    The installation is like that :
    site2 is in a subdirectory of the site1 root.

    The .htaccess are already rewrited base :

    site1.com .htaccess :
    `

    IndexIgnore *


    RewriteEngine On

    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [L]
    RewriteRule ^.*/?$ index.php [L,QSA]


    RewriteCond %{HTTP_HOST} ^site2.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.site2.com$
    RewriteRule ^/?$ "http\:\/\/www\.site1\.com\/site2/" [R=301,L]
    `
    site2.com .htaccess :
    `

    IndexIgnore *


    RewriteEngine On
    RewriteBase /site2
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [L]

    RewriteRule ^.*/?$ index.php [L,QSA]


    `
    But when I try to connect to site2.com, I'm redirected to site1.com.
    Something must be wrong, but... what ?
  • acrylian Administrator, Developer
    Again it would be all easier if you would redirect the domain via your host directly to the /site2 folder.

    Also your domain redirection should go before the other rewrite ones. Also one rewriteCond per one RewriteRule.

    Try this:
    `
    RewriteCond %{HTTP_HOST} ^site2\.com$ [NC]
    RewriteRule ^(.*)$ http://www.site1.com/site2/$1 [L,R=301]
    `
    An then no `RewriteBase /site2` but `RewriteBase /`. There is no folder used anymore if you redirect it!
  • flu Member
    Hi,
    "Again it would be all easier if you would redirect the domain via your host directly to the /site2 folder. "
    Already done.

    I've made the change but site2 is still redirected to site1.

    Here are the .htaccess :

    Site1.com :
    `

    RewriteEngine On

    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [L]

    RewriteRule ^.*/?$ index.php [L,QSA]




    IndexIgnore *

    `
    Site2.com :
    `

    IndexIgnore *


    RewriteEngine On

    RewriteCond %{HTTP_HOST} ^site2\.com$ [NC]
    RewriteRule ^(.*)$ http://www.site1.com/site2/$1 [L,R=301]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [L]

    RewriteRule ^.*/?$ index.php [L,QSA]


    `
    Site2.com is still redirected to site1.com.
    Help (I need somebody, heeeelp).
  • acrylian Administrator, Developer
    So you already redirected the site2.com domain to the /site2 folder? Then you don't need to do the same using htaccess… And if you are already on the site there is nothing to redirect via that sites htaccess because that itself now redirects back to site1.com/site2 again…

    You are really over complicating things here…
  • flu Member
    "You are really over complicating things here… "
    That's all me... I'm giving a try right now.
  • flu Member
    Then, site2.com is still redirected to site1.com.

    .htaccess site1 :
    `

    IndexIgnore *


    RewriteEngine On

    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [L]

    RewriteRule ^.*/?$ index.php [L,QSA]


    `
    .htaccess Site2 :
    `

    IndexIgnore *


    RewriteEngine On

    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [L]

    RewriteRule ^.*/?$ index.php [L,QSA]


    `
    Stuck.
  • acrylian Administrator, Developer
    Clear your browser cache and make sure the web server setting via your host are correct. Sometimes these take some time to work.
  • I think you really need to study rewrite rules.
    First you need either a rewrite base or you need to explicitly include folder names or your file tests and redirects will most likely look in the wrong place. Then your config file will need to have have explicit defines for the WEB and server paths because zenphoto will not be able to sort things out.

    I am at a loss as to why you do point your domains directly to the correct folder and let everything work normally. If you actually succeed the way you are going you will have created for yourself a maintenance nightmare.
  • flu Member
    Ok Stephen.
    In fact I say "ok" but I don't get it at all.
    I can't change something on site1.com (production) but I can change anything on site2.com.
    Concretely, what am I supposed to do to avoid "a maintenance nightmare" ?
  • acrylian Administrator, Developer
    Again, you are really overcomplicating things. As long as you have both sites under separate domains there is no change to any of the sites. Production or not.

    Really, again my suggestion to put both in their own folders in the root of your webspace and redirect the domains via your webhost's interface to those folders. Then run setup on each or change the rewritebase htaccess entry to `rewriteBase /` and you are done. Nothing will change for any visitor and you have both sites clean separated.

    If the 2nd is a clone you might needto re-clone the files but as long as you use the same database credentials on that clone (save the config file) and same albums also nothing will be harmed.

    It is really that simple.
  • flu Member
    Ok guys, thank you for the advices.
    I couldn't figure out how to put the main domain name in a directory without it to appear in the adress bar so I just left it like it in the root, but site2.com works fine now.
    Thanks again.

    (yeah, it's a long way til' the top if you wanna rock'n'roll)
  • acrylian Administrator, Developer
    I couldn't figure out how to put the main domain name in a directory without it to appear in the adress bar
    I think you are not only overcomplicating but you might also over confusing yourself…:-)

    It is really this simple and your host for sure has a domain management tool for it:
    www.site1.com -> site1 folder
    www.site2.com -> site2 folder
  • flu Member
    You're right but it gives me :
    http://www.site1.com/site1 folder instead of http://www.site1.com/

    Thank you anyway.
  • acrylian Administrator, Developer
    Then something is not set right like an redirection in a htaccess file. Again, either you do it via htaccess OR your webhost settings.
  • Hi guys,
    I've read many things on this forum and others and tried many things too these days about that, but I still got a problem.

    With this .htaccess on the root folder :
    `
    RewriteEngine On
    RewriteRule ^$ zpdirectory/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ zpdirectory/$1
    `
    The ZPdirectory doesn't appear in the URL when I type www.mysite1.com but it still appears in the URL navigating through albums and images.
    I've updated to Zenphoto 1.4.5.7.
    I've re-run setup, refreshed the database, cleaned the html cache, even tried some exoctic stuffs with zenphoto.cfg.php but the subfolder still appears in the URL.
    Did I really miss something in order to hide that damned subfolder in the URL ?
    Do I have to change something manually in the parameters, in the root .htaccess or in the /ZPdirectory/ .htaccess ?
  • acrylian Administrator, Developer
    Again, if you don't want to have the folder ZP is installed in in the URL redirect the domain to the folder so the folder becomes the root. Either do that via your host's server config backend or on the root htaccess. As long as that is not done, you will get the folder in the url because that is the path.

    There are loads of instructions like
    http://webdesign.about.com/od/mod_rewrite/qt/site_redirects.htm
  • There is really ONLY one way to do what you want. You MUST have a domain that points directly to the ZP install folder. Anything else simply does not work.

    Rewrite rules simply change links, so you could have a rule in domain1 that redirects to domain2. Or you can have a link that redirects domain1 to domain1/folder. Neither of these is what you are asking for.

    So, contact your host and find out how to setup "subdomains" for your site. If you have a reasonable hoster that will be quite simple and allow you to have things like:

    www.sbillard.org
    testalbum.sbillard.org
    testalbum-2.sbillard.org

    that all point to "root level" Zenphoto installs.

    I will mention again that I do not understand why you are so unwilling to follow our advice. But rest assured, this is the end of this discussion.
This discussion has been closed.