Getting started with Drupal 6 in a subfolder.

So a few days ago I finally was able to map Drupal 6 to my www subdomain without putting it in the root folder that the subdomain points to. The idea is to get the URL to become subdomain.domain.com instead of subdomain.domain.com/folder. Ideally you would be able to just point the subdomain to whatever folder drupal is installed to, however this doesn't seem to be an option at least for some domain name resellers. Fortunately there is a way around this. It involves using .htaccess files and mod_rewrite rules, which are allowed by most hosting services. It's a bit of a long way around to what should be a simple problem, but at least there is a solution.

I found some explanations to be inadequate, but a good place to start is a Drupal post started by pulisfier here. The idea gets a bit further developed in the comments section. I found the solution to my particular problem in what seems to be the installation document, but the sections are not included in the the INSTALL.TXT file for whatever reason, here.
The section in particular that helped is headed as "!Installed globally (no symlink), accessed as root." The problem is that I needed to install Drupal in a subfolder of the subdomain location. We will call the subfolder /drupal.

In the site root, you will need your .htaccess file to have lines that resemble the following.

RewriteEngine on
RewriteRule ^$ /drupal/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /drupal/$1 [L]

What this does is rewrite links and requests for resources from the subdomain to the appropriate mapping of the subfolder called drupal.

In the drupal installation folder you will need something like this in your drupal .htaccess file. This will replace the contents of the existing "Clean URL" rewrites.

RewriteBase /drupal
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /drupal/index.php?q=$1 [L,QSA]

What this does is rewrite links and requests for resources at the subdomain subfolder into a "clean URLs" compatible format.

If you want to force the subfolder to NOT appear in the URL, you will have to modify $base_url variable in /drupal/sites/defaults/settings.php. If the location of the installation is http://www.example.com/drupal and you want to force the url to become http://www.example.com you will set it as such (http://www.example.com). Make sure you uncomment it before saving so that the change is applied, remove any "#" symbols appearing before the assignment on the same line.

Hello and thank you sir for

Hello and thank you sir for posting this.
It really helps me a lot.
I am new to drupal.

Nice post :) web hosting

Nice post :)

Hey

Thanks for this guide.

Hello!

Thanks for sharing this!

Hey ya

This is a very useful guide.
thank you for sharing.

Hi..

Thanks for the help dud. This article is really very helpful. Thanks once again..

Thanks for this write code

Thanks for this write code that we can use.

This will be perfect. I try

This will be perfect. I try and keep my files on my site organized but this creates some really ugly urls.

Thanks for the guide. There

Thanks for the guide. There is one more thing I need help with.
How do you by-pass the .htaccess redirect rules in regards to the looping issue? 

Re: Thanks for the guide. There

I'm not sure what you mean by looping issue. Do you have some steps I can try to reproduce this issue?

Thanks for this rewrite rule

Thanks for this rewrite rule code that I can use on my site. I used to host with a company that allowed me to force from the back end but my new host does not allow me to do that.