Hi,
In advance: I have spent nearly a day reading and trying out recommendations in dozens of relevant multi-site posts already !
I have a top-level "default" Drupal site running ok directly under my public_html, which would (using example.com) be accessed as:
This corresponds to .../public_html/ on my server.
I want to have a 2nd Drupal-site (own database, sharing same code-base) accessed via subdomain:
The code-bases I've setup are:
.../public_html/modules/... (Drupal core)
.../public_html/sites/all/modules/... (shared extensions)
.../public_html/sites/default/modules/... (the "main" http://www.example.com site running now)
.../public_html/sites/subdomain.example.com/modules/... (target for subdomain)
Currently http://subdomain.example.com is always accessing the 'subdomain' folder created when the subdomain was created using the host's CPanel:
../public_html/subdomain
If I call that as just http://subdomain.example.com I get:
403 Forbidden You don't have permission to access / on this server
If I call a test page http://subdomain.example.com/test.html it loads as expected at test page at .../public_html/subdomain/test.html.
I have tried redirecting (both using the CPanel subdomain redirect and be manually editing the .htaccess RewriteRules),
however it seem to fails, because it always has to eventually be seen as coming from http://www.example.com,
which falls through to the default site (presumably because Drupal is looking for subdomain.com.au in the calling URL,
which has been remapped).
Q1: Does anyone know of a way I can edit .htaccess either at the top-level OR under ..../public_html/subdomain/.htaccess to achieve this ?
Q2: Can one use this vhosts approach in .htaccess instead of in the confs files ?
DocumentRoot /home/user/public_html
ServerName www.example.com
DocumentRoot /home/user/public_html
ServerName subdomain.example.com
Q2: Is there another way ?
Glad for advice,
Darren (webel)
PS: I have read and tried at least:
Multi-site installation and set-up AND every page it refers to !
Multiple domains or vhosts using different databases (can't do it that way with CPanel)
Comments
The second site,
The second site, http://sub.example.com, must also resolve to public_html and not to public_html/sub, because in the latter case Drupal's index.php won't be loaded and Drupal will be unaware that someone is trying to access a site.
You can't set up vhosts in .htaccess.
You can't use .htaccess redirects or rewrites either, because they change the request URL. When you arrive at the destination directory and index.php is loaded, the request URL must be maintained, otherwise Drupal won't be able to decide which site was requested.
The simplest solution, if your cpanel allows, is to modify your subdomain to point to public_html.
If this is not possible, and if you don't have access to Apache's httpd.conf, the only other solution is to replace the public_html/sub subdirectory with a symlink pointing back to public_html.
Delete the "sub" subdirectory and then replace it with a "sub" symlink:
If you don't have shell access and you can't use that command, then you can try creating a php script to do that for you (http://php.net/symlink). You may need to adjust the permissions of your public_html directory first, so that the script can write the symlink file in it.
Hi cog.rusty, Am so grateful
Hi cog.rusty,
Am so grateful for your (as so usual) prompt and helpful reply, it confirms everything I suspected.
>The simplest solution, if your cpanel allows, is to modify your subdomain to point to public_html.
As far as I can tell the CPanel does not permit that (I have a ticket on that to my hosting company pending).
I don't have access to httpd.conf (I am asking hosting company whether they can do vhosts for me perhaps).
I don't have shell access so I can't do symlink that way.
> .. you can try creating a php script to do that for you (http://php.net/symlink)
I tried
Fantastic, it worked ! And after fiddling a bit with install it is up and running.
Above all, my wife is now very happy because the subdomain site is for her !
Webel
Webel, "Elements of the Web", Scientific IT Consultancy,
For UML, UML Parsing Analysis, SysML, XML, Java, symbolics
http://www.webel.com.au (under migration to Drupal)
"See a need, fill a need.", Bigweld (from "Robots")
Webel IT Australia, "Elements of the Web", Scientific IT Consultancy,
For PHP-driven Drupal CMS web sites, Enterprise Java, graphical UML, UML Parsing Analysis, SysML, XML.
multi-site setup with cPanel
When I installed Drupal 5 a couple of years ago, I didn't really know what I was doing but managed to get multi-site running in a rather convoluted way. I've just started working with Drupal 6 and have a simple method that seems to be working nicely. I put Drupal 6 in public_html/drupal6. Then when adding a domain in cPanel, instead of taking the suggested directory, I change it to drupal6. And then, of course, adding the domain name and other good stuff to drupal6/sites. The only disadvantage that I can think of is that you can't have a separate .htaccess file for each domain. Good luck.
A question for
A question for Jednorozec...
In your above January 25, 2009 comment you state:
And then, of course, adding the domain name and other good stuff to drupal6/sites.
I have created the subdomain with cPanel and pointed it to the drupal folder, but I am lost when "adding the domain name and other good stuff to drupal6/sites."
The subdomain created doesn't appear in the drupal6 folder as it would by placing it in the public_html folder. I created a folder with the subdomain name in drupal6/sites and placed a files folder and copy of the default.settings.php file with permissions...
Just figured it out while I was trying to explain it here ! I forgot the created settings.php file as when the original install is done.
I do have to say that making the MACHINE do the work ( writing the configuration and link... then writing the settings.php [ and even changing permissions back !!! :] is a lot easier than all the other methods here in this forum... just gotta be smarter than the machine huh ?
THANKS