Drupial - Installing drupal in a subfolder

Welcome to my first ever drupial. What is a drupial you say well it is a catch phrase on the words drupal and tutorial. Mostly these will apply to drupal tutorials but they can also fall in the form of any web based or programming tutorial that I find useful.

With that said lets get on the way. I have recently installed drupal but I wanted an easy way to switch from drupal5 to drupal6 with a clean install so the only way I could think of is installing drupal in a subfolder and having it show up as the root folder.

The first thing to do was to install drupal into a folder called drupal5.
After that I needed to create a new .htaccess file in my root folder to direct everything into my new subfolder.

Here is an example file:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^$ drupal5/index.php [L]
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/drupal5%{REQUEST_URI} -f
RewriteRule .* drupal5/$0 [L]
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* drupal5/index.php?q=$0 [QSA]

RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^$ drupal5/index.php [L]
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/drupal5%{REQUEST_URI} -f
RewriteRule .* drupal5/$0 [L]
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* drupal5/index.php?q=$0 [QSA]

You would just need to replace the example.com with your domain name. The first section is so people can navigate to your site without the www. Example: example.com and the second section is to navigate with www.example.com

The next step is modify your settings.php file located in your drupal folder. Navigate to drupal5/sites/default/
And open the settings.php file.

In that file there is a line that says
# $base_url = 'http://www.example.com'; // NO trailing slash!

All you need to do is uncomment that line and change the example to your domain name.

Using this technique I have successfully had a multisite drupal installation work perfectly. I have a couple subdomains and they all point to the same drupal folder and everything works perfectly including clean-urls and redirects.

And as soon as I put drupal6 on my site I can just change the folder name from the .htaccess and everything should be good to go.

Note: this is also very helpful if you would like multiple drupal installations. For this you just point each domain to different folders