Remote Web Host

If your website is set up on a remote web host, such as Green Geeks or Go Daddy, you will be using a web app like cPanel to configure the Apache web server. cPanel is actually creating VirtualHost configuration settings for you behind the scenes, among the many things that it does. You will find that this works fine for any secondary domains that you set up, (those additional web spaces that you configure from a web reseller account after the first one is set up), and subdomains (like . You can adjust the Document Root for secondary domains and subdomains to point to the subdirectory where you have Drupal installed.

But for your primary domain - the one you used to set up your remote hosting account - cPanel has pointed the DocumentRoot to your webroot directory, (the www folder), by default. This is good. This setting allows you to access all of the preconfigured features that your web host has already set up for you, such as site monitoring tools and editors as well as the hundreds of web applications that can be installed for you with one click. When you install Drupal in a subdirectory of your webroot and access it from the primary domain, however, it looks like its in a subdirectory - with a URL like instead of You could ask your site host to "fix" the DocumentRoot directive for you, but that's going to break all kinds of cool stuff. Fortunately, there is a better way.

Those funny looking .htaccess files that you see in some directories are there to send more configuration information to Apache web server on a per-directory basis. They can be used to over-ride many of the settings in the Apache configuration files. If you are not seeing any files that start with a dot in your File Manager, check the box that says Show Hidden Files as you start it.

If you intend to run a single web site on your Drupal installation and you only access it using one domain name, copy the code below into a .htaccess file in your webroot. You can create the file if it doesn't already exist.

# *** Primary Domain Rewrite for Drupal in a subdirectory ***
# Add this script to the .htaccess file in your webroot. 
# Change 'example\.com' to your domain name. Leave the slash.
# Change 'drupal-directory' to the subdirectory where Drupal is installed.

RewriteEngine ON

# Check if request is for a file in Drupal and rewrite it.
RewriteCond %{HTTP_HOST} ^(www.)?example\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/drupal-directory%{REQUEST_URI} -f
RewriteRule (.*) drupal-directory/$1 [L]

# Send requests for root of domain to Drupal index.php.
RewriteCond %{HTTP_HOST} ^(www.)?example\.com$ [NC] 
RewriteRule ^(/)?$ drupal-directory/index.php [L]

# Other requests for this domain are sent to Drupal index.php. 
RewriteCond %{HTTP_HOST} ^(www.)?example\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/drupal-directory/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) drupal-directory/index.php?q=$1 [QSA]

Edit the code to reflect your domain and your Drupal directory, save it, and it should start working immediately to direct requests to your Drupal install.

If you still see the subdirectory appended to the browser location, go to your Drupal site folder (drupal-directory/sites/ and edit the [i]settings.php[/i] file. Set $base_url = ''; . Now it should work as expected and still let you access other scripts in your webroot.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.