There seem to be a huge number of posts on this subject - I think I've read them all, and I'm still unable to see why I can't get this to work.

My existing non-drupal site uses cPanel hosting and exists in /public_html. I've developed a drupal-based replacement site in /public_html/drupal and, during development, accessed it using the subdomain drupal.mysite.com with DocumentRoot set to /public_html/drupal. No problems. Now I want www.mysite.com to load the site from /public_html/drupal.

The ISP are unable/unwilling(?) to change DocumentRoot in httpd.conf so told me to update /public_html/.htaccess to include the following:

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$ 
RewriteCond %{REQUEST_URI} !^/drupal/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /drupal/$1 
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$ 
RewriteRule ^(/)?$ drupal/index.php [L]

This appears to cause any request that starts with www.mysite.com or mysite.com to be changed to be www.mysite.com/drupal. That works in that www.mysite.com now loads from /public_html/drupal, but all URLs are now of the form www.mysite.com/drupal/rest-of-url

I then changed $base_url in settings.php to be 'http://www.mysite.com/drupal', thinking that this would cause Drupal to strip off what Apache had inserted. I purged Drupal's cache and my browser's cache, but all URLs continued to include "drupal".

I had expected the steps above to achieve what I want, so finally, I experimented with changing /public_html/drupal/.htaccess. In turn, I uncommented:

RewriteBase /drupal

then:

RewriteBase /

and purged caches between changes. Neither of these resolved the problem.

Can anyone see what I might be missing here? The site appears to work fine with "drupal" in all the URLs, but I would really like to remove it.

Thanks.

Comments

kgm’s picture

  1. Make the changes described to /public_html/.htaccess
  2. Change settings.php to include $base_url = 'http://www.mysite.com'

I.e., do not use $base_url = 'http://www.mysite.com/drupal', despite what the comment in settings.php implies.

$base_url, if defined, appears to be what drupal pre-pends to its 'local' URLs. The changes to /public_html/.htaccess cause the site to be accessed via URLs starting http://www.mysite.com/drupal. With $base_url, undefined, that's the base URL drupal pre-pends. Defining $base_url = 'http://www.mysite.com/drupal', as I did originally, simply instructs drupal to do what it was already doing by default.