Last updated March 14, 2010. Created on March 14, 2010.
Edited by remedios. Log in to edit this page.

When you're on a shared host like Lunarpages, you'll sometimes need to install drupal in subfolder. Often, you'll want to make it look like the subfolder is the base URL. To do that, edit .htaccess in your domain's public HTML root to redirect requests for pages, as instructed here:

You'll need to make sure that the redirect-to-subfolder command in your domain's .htaccess file isn't redundant with the settings.php (in sites/default/) $base_url line. If they're redundant, you'll get an infinite loop during certain tasks.

In sites/default/settings.php, you will have: $base_url = ''; // NO trailing slash!

DON'T list the base URL as$base_url = '';

To prevent an infinite redirect loop with sophisticated external connection applications and other errors, let the .htaccess file in the public HTML root (one folder above the subfolder) do the redirecting. Don't include your subfolder in your settings.php Base URL. This may seem obvious, but it is easy to miss because the redundancy doesn't cause problems until you use sophisticated programs like the fb modules.

Looking for support? Visit the forums, or join #drupal-support in IRC.


Neil’s picture

My site is located off of the web server root in a subfolder called foo. Before following the instructions in this article my site would appear as After it would appear as, which is what is wanted, but when clicking on the login menu item I get :

Index of /user

Name Last modified Size Description
Parent Directory

Basically a directory listing with no files in it. I have checked file ownership/protection and everything appears correct, at least to me.

I am new to Drupal so any help would be appreciated.

Runs on:

with Php 5.1.6


shane2peru’s picture

Ok, I setup drupal in a subfolder we will call drupal inside of public_html folder. I then created a and pointed it to public_html/drupal
Everything was fine, but I setup the sub.domain through cpanel, and made the document root to be drupal. I built my web site to my liking.

Now I follow these instructions to configure my primary site to be pointed to public_html/drupal following this guide with the lunarpages info, and the redirect works, however my site has no theme! All links seem to work, just no menu's, no blocks, no color, nothing, just words and links.

If I create a redirect with the cpanel it all works fine, except, when I go to the primary domain it looks just like that in the link. AS soon as i click a link, I get the <-- trailing folder name included in the url and it doesn't go away.

As specified in this guide I set the settings.php file to have the base URL as it should, without the folder. Any ideas would be greatly appreciated as I have played with this for several hours trying to get something set correctly. I commented out all the Rewrite stuff so my static site is still functioning for the time being, however this is quite annoying for me.


jonahruh’s picture

Hi Thanks for this post, I followed directions above and checked my settings.php file. My index page shows without the drupal folder, /d6, but when I click on any subpage menu, /d6 is still part of the url. For example If if i go up and delete /d6 from the url, the page will still display correctly and the /d6 won't get automatically reinserted into the url. But when i click on a menu item directly the /d6 is there. Do i need to rewrite more than just /index.php?

jonahruh’s picture

Uncomment and put site's domain in baseurl line in settings.php

smerny’s picture

I have a similar but totally opposite issue. I have a directory within Drupal that I don't want Drupal to touch. I am trying to do auto indexing (file directory pages) on this directory and all subdirectories... I've tried Options +Indexes and turning off RewriteEngine but nothing seems to work.

I have a sites/default/files directory, if I try going directly to this directory I get my Drupal headers with a message that says it couldn't find this page (instead of displaying a file listing for this directory). However if I go to something like sites/default/files/someFile.html, it will work as I expect (only showing the files content, no drupal headers). I posted my question here as well: