Hey All,
Here is the set up I need to have going:
I plan to install 1 drupal installation at the root of www.mainsite.com
However, I would like to have a separate drupal site up on www.mainsite.com/site2
Don't worry, I know how to share tables. I plan to have all the drupal's running on the same database with different prefixes (except for the shared tables having a 'shared_' prefix).
I already know how to do this for subdomains. That is, site1.mainsite.com that is actually simple to do.
Basically, I think if I can tell my sites folder to look for different drupal set ups in subfolders, that would be ideal.
/sites/mainsite.com
/sites/site1.mainsite.com (this is how it is done with a subdomain)
but how do you say
/sites/{mainsite.com/site1}
How do you make drupal recognize that?
OR, how do you create a subdomain, like site1.mainsite.com, and have it point to www.mainsite.com/site1 and have the drupal set up within mainsite.com not interfere with it?
Hope this makes sense to everyone. Let me know if you need a clarification...
Comments
The simplest way is to upload
The simplest way is to upload a second Drupal installation in the subdirectory and forget about multisites and sites/sitename directories. It will work fine.
But if you want to make it a multisite and to use the same drupal installation for everything, then:
If you are going to be accessing the second site using http://site1.mainsite.com then you need a sites/site1.mainsite.com directory for its settings.
If you are going to be accessing the second site using http://www.mainsite.com/site1 then you need a sites/mainsite.com.site1 directory for its settings.
In both cases, the site's URL must lead to the same Drupal installation directory where Drupal's index.php file is. For example:
http://www.mainsite.com -> public_html (if Drupal is installed here)
http://site1.mainsite.com -> public_html (the same)
http://www.mainsite.com/site1 -> public_html (the same)
You can achieve these with symlinks or with other methods depending on whether it is your own server. Drupal will figure out which site you want by comparing the http request with the names of your sites/ subdirectories.
Follow up...
Thanks,
I did just that, but it didn't work... (drupal still thinks that www.mainsite.com/site1 is a missing page and gives the 404)
In my /sites/ folder I renamed the directory to /sites/mainsite.com.site1
And in the settings.php file for it, I changed the base URL to
$base_url = 'http://mainsite.com/site1';Anything we could be forgetting. Not sure what symlinks are...
If browsing to
If browsing to http://www.mainsite.com/site1 leads to a public_html/site1 directory, there is no Drupal there to run. You need to find a way to make the URL http://www.mainsite.com/site1 to lead to the public_html directory.
A symlink is a special Unix file, something like a shortcut, which you create where the site1 subdirectory was supposed to be but it leads back to Drupal. You could create one either with a Unix command if you have shell access, or by running a PHP script with a symlink() statement.
Okay great! I got it to
Okay great! I got it to work!
However... here is the thing now..
I want to take out all ^www\. from the sites. So in the .htacess I enabled:
And although it works for every type of URI, it does NOT work for the symbolic-link site.
That is,
www.example.com/page1will go to example.com/page1But,
www.example.com/site1/page1sends me to example.com/page1How do I fix that?
I tried playing with the htaccess, creating new mod_rewrite functions, added:
But that didn't work either.
Whats the solution here?
Thanks!
The first one should work for
The first one should work for all your sites, as it is.
Your modification doesn't work because the HTTP_HOST server variable cares only about the domain name and not about the URL path.
Make sure that you haven't left an old
$base_url='http://example.com';line in the settings.php file of site1.Did you have to set
RewriteBase /in your .htaccess file, or did it work without it?Right my bad. The "Rewrite
Right my bad.
The "Rewrite Base /" line seems to do nothing. I have taken it off and put it back in. Not sure if it applies to me. Should I keep it on regardless as a safeguard?
Also, all the $base_url's are set.
So for site1
$base_url = 'http://example.com/site1';
for the mainsite
$base_url = 'http://example.com';
As for .htacess
I changed it to this:
However, now the "www" rule doesn't work on the /site1/ site.
When I switch the order to:
I am back to the same problem as before...
I would restore .htaccess to
I would restore .htaccess to the original, modify only
and then browse to http://www.example.com/site1 and do a hard reload with Ctrl+F5.
Interesting.. When I do a
Interesting..
When I do a hard reload with Ctrl+F5, it works!
But, when I just simply type in the url http://www.example.com/site1 and press enter, it takes me to http://example.com
What do you think?
The hard reload should have
The hard reload should have updated the browser's cache. Does this still happen? Try clearing the browser's cache.
No... Cleared my cache and
No... Cleared my cache and cookies. Nothing..
Cntrl + F5 works, but a regular reload does not..
I'll just write out the URL. its a production site, so not much to see yet.
http://www.thinklanguage.com/french
http://thinklanguage.com/french
Weird. I can see the problem,
Weird. I can see the problem, so it is not your browser's cache. And Ctrl+F5 does not really load the second site. Are you sure that there is no other .htaccess file in a parent directory with any rewrites which affect subsites?
Is the name of the second sites's settings directory
sites/thinklanguage.com.french?Does anything change if you set
RewriteBase /?It is difficult to suggest anything positive because I don't have this problem with my subsites and cannot test it, but try setting a different RewriteBase before any group of rewrites: Instead of the other .htaccess modification, go to the end of .htaccess and replace:
with
As far as I know, there
As far as I know, there should only be 1 .htaccess file and it is located in the public_html directory..
Yeah the french site is at /sites/thinklanguage.com.french and the base_url there is http://thinklanguage.com/french
I tried copy and pasting your code into my .htaccess file and no-go :(
Man, this is looking kind of bleak. But you mentioned this works on your own server? So that gives me some hope that there is a way.
I tried changing the order of some things, but still, no go. In fact, now, going to anything like http://thinklanguage.com/french/user/1 actually takes you back to the http://thinklanguage.com/user/1 page even though the URL keeps the word "french" in it...
Is there maybe another way of pointing the /public_html/french link to /public_html/ without using symlink?
The only other way of
The only other way of pointing subdirectories back to Drupal are apache "Alias" directives, which map URL paths to directory paths.
But these (a) work only in apache's .conf files and not in .htaccess, and (b) they *really* need their own RewriteBases. (Symlinks don't, because normally they behave just like real directories.)
I just noticed one more weirdness: http://thinklanguage.com/?q=user redirects me to http://thinklanguage.com/user, which normally shouldn't be happening.
What else do you think I
What else do you think I could try on the .htaccess then...?
Thanks so much for sticking around this long, by the way. I think we are close.
I've been able to overcome just about every other weird problem, there has got to be a solution to these issues.
I'm trying stuff like
I'm trying stuff like this:
That doesn't work, but could we play with code like that? I am not sure if the RewriteBase needs to go before or after a block of code.
I wish there was a way we could differentiate operations between the subdirectories. That is, when we are in the /french/ symlink, we could apply its own .htaccess file. When we are in the /public_html folder, it would use its own .htaccess..
Yes!! I got it!! Here is the
Yes!! I got it!!
Here is the code that makes it work!!
I basically played around with your stuff, but it appears to work.
Thanks for sticking around!! I hope I can one day help you like this
I have found a clear
I have found a clear explanation here for an identical problem:
http://www.andrewrollins.com/2008/01/22/wordpress-and-htaccess-password-...