Install Drupal in a subdirectory, but access it as root

I wanted to install Drupal in a subdirectory, for instance ~/public_html/drupal, and still access it as root.

The theory is simple: put Drupal in a subdirectory then add a .htaccess file in the root directory that redirects non existing URL's to '/drupal'. But in practice it proves to be trickier than I thought.

So, here is the code for the .htaccess file:

Options -Indexes
Options +FollowSymLinks

<IfModule mod_rewrite.c>
RewriteEngine On

# skip processing the drupal files
RewriteCond %{DOCUMENT_ROOT}/drupal%{REQUEST_URI} -f
RewriteRule .* drupal/$0 [L]

# process drupal urls
RewriteCond %{HTTP_HOST} ^kenjiru\.ro|www\.kenjiru\.ro$ [NC]
RewriteRule ^$ drupal/ [L]

# the actual redirect
RewriteCond %{HTTP_HOST} ^kenjiru\.ro|www\.kenjiru\.ro$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ drupal/$1 [L]
</IfModule>

I specified the domain because I'm having other addon domains hosted on the same document root.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Image links with 'rel="lightbox"' in the <a> tag will appear in a Lightbox when clicked on.

More information about formatting options

User login

Who's online

There are currently 0 users and 1 guest online.