By calrockx on
I just installed Drupal on my site, and am wondering about this, or future, installs...
Is it possible to put all the Druapl install/core files in a directory within the root directory, say a "drupal" folder?
Just for the sake of a less cluttered root directory.
I searched about this but didn't really find a solid answer.
Comments
Yes. If you install it into
Yes.
If you install it into an ordinary subfolder, then the url will look like this:
http://mydomain.net/[subfolder]/
If you install into a properly created subdomain, the url will look like this:
http://[subdomain].mydomain.net
The subdomain is portable, the folder is not. ie. in future, by using the subdomain you can easily transfer your site to root or to another subdomain. With the folder, you'd have to edit all your internal links to images and files if you wanted to move the site.
Also, if you don't want the subdomain to show in the url (so the users think the site is in root), you can use some htaccess to 'hide' the subdomain in the url.
Okay, so I could install
Okay, so I could install Drupal to a subdomain like drupal.example.com and then use some htaccess magic to hide the subdomain name.
But then, say I want to apply some of my own CSS, could I put the style.css file in example.com/css/styles.css and still have it apply to the Drupal content? Or put images in example.com/images? It seems all I'd have to do is just give the absolute paths to those files and everything should work?
> so I could install Drupal
> so I could install Drupal to a subdomain like drupal.example.com and then
> use some htaccess magic to hide the subdomain name.
Yes. I am doing it with the site I'm currently developing.
I haven't experienced any problems yet.
> could I put the style.css file in example.com/css/styles.css
Yes, but not exactly as you are thinking....
Your subdomain would be a folder: public_html/drupal
In this /drupal folder you'd have the normal installation files, including /sites
In /sites, you'd have the normal folders /all and /default.
In /all you'd have /themes and /modules, as normal.
In /themes you'd have your theme folder, whatever it is called.
Your style.css for that theme belongs in there, as normal.
Nothing is different, with regard to the internal paths.
For instance, your 'file system' path for the upload module would be:
public_html/drupal/sites/default/files/ instead of public_html/sites/default/files/
But notice that the internal paths, the highlighted bits, are the same.
Don't mix up the file location with the url; they are separate things.
All the browser cares about, and knows about, is the url in the browser bar.
It doesn't know anything about the actual locations and paths on the server.
So, suppose you are visiting the page: http://drupal.domain.net/blogs/1
This page has an image in it. The source is:
<img src='/sites/default/files/images/image01.jpg' />That is called a 'partial absolute' path.
The first slash means 'add this onto the end of the domain'.
So the browser will fetch the image at:
http://drupal.domain.net/sites/default/files/images/image01.jpg
which (due to the way subdomains work) is the same as:
http://domain.net/drupal/sites/default/files/images/image01.jpg
which matches the actual location of the image:
public_html/drupal/sites/default/files/images/image01.jpg
Here is the htaccess.
This goes in the root (public_html) htaccess file, not in the /drupal htaccess file:
## In /drupal/sites/default/setting.php, edit - $base_url = 'http://domain.net';
#
RewriteCond %{HTTP_HOST} ^domain\.net$ [NC]
RewriteRule ^$ drupal/index.php [L]
RewriteCond %{HTTP_HOST} ^domain\.net$ [NC]
RewriteCond %{DOCUMENT_ROOT}/drupal%{REQUEST_URI} -f
RewriteRule .* drupal/$0 [L]
RewriteCond %{HTTP_HOST} ^domain\.net$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* drupal/index.php?q=$0 [QSA]
You need to swap 'domain.net' for your own domain
And swap 'drupal' for whatever you call your subdomain.
Bear in mind that you won't be able to use your root for any other scripts, because the drupal install is now using the url for the domain, even though it is installed in a subdomain. So any other scripts will have to be accessed through a subdomain url or a subfolder url.
Also note that if you use a weird host, like 1&1, who has customised everything, this htaccess might not work.
Thanks Anti, that helps out.
Thanks Anti, that helps out. :)