Make drupal working in a subdirectory

  • Tested on HostMonster.com (main domain)
  • Drupal 5.7
  • e.g. drupal57 as public_html subdirectory containing Drupal codebaseI’ve an existing Drupal installation within public_html on HostMonster for my main domain. Here the steps I’ve done to move the codebase on a subdirectory without changing URLs:
  1. Put offline the website: go to Administer > Site Maintenance
  2. Backup your codebase (Select all > Compress via Cpanel: remember to put your backup file outside public_html to prevent download)
  3. Move codebase via File Manager:
    • Go to CPanel > File Manager
    • Create a new directory (e.g. drupal57)
    • Use “Select all” to check all codebase files, then deselect drupal57
    • Move all selected files to drupal57, including .htaccess file

    All privileges will be maintained.

  4. Now, create an empty .htaccess file on public_html (note: if you have chosen PHP rendering via FastCGI, you have to go to PHP Configuration and set your preferences, It’ll be add a new line on your .htaccess on public_html, creating it if necessary)
  5. Add new .htaccess lines following the HostMonster’s How to make a subfolder the main folder for your main domain.
  6. Edit drupal57/.htaccess (via file manager or locally) uncommenting RewriteBase and setting it to /drupal57 (e.g. RewriteBase /drupal57) Update: errors occurs when used by other subdomains: do not use
  7. Edit drupal57/sites/yoursite.com/settings.php and uncomment $base_url line (e.g. $base_url = ‘http://www.yoursite.com’; )
    Update: This is useful when used on main domain (yoursite.com, http://www.yoursite.com) following step (5).

    • If you want main domain (e.g. yoursite.com) and subdomain (e.g. mysub.yoursite.com) to display the same content, you have to leave this line uncommented
    • When you transform your main domain into a subdomain (e.g. when you have a brand new site to promote to main domain), you have to comment this line.
  8. Put your site online

Now try to navigate your site. Your URLs are the same you had before moving your files.

Advertisements

2 thoughts on “Make drupal working in a subdirectory

  1. Pingback: Cambiar URL de instalación Drupal | Blog Rodrigo Torrens

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s