Posted by texas-bronius on November 19, 2010 at 9:16pm
I am at a loss here.. A site I am working on has been under a /beta folder sub to webroot (/public_html/beta), and to make it live, rather than moving to root (and having naming conflicts with other lesser apps), we've opted to have htaccess rewrite ^www. over to /beta. Looks good at first, but now Drupal produces links and reference to webassets as /beta/contact, /beta/about, etc.
Is there a way around it? I have tinkered with $base_url in settings.php and RewriteBase in Drupal's .htaccess.
Would prefer not to employ a proxy. Is there something simple we are overlooking?

Comments
Complete solution to Drupal in subdirectory but serve up as www/
Here is what worked to host Drupal in a folder sub to webroot (public_html) and still have it served up on www (without Drupal appending the subdirectory in its generated paths and urls).
Need webroot (outside drupal) /public_html/.htaccess rewrites to catch straight domain (www and not, but not subdomains, etc) requests:
...RewriteCond %{HTTP_HOST} ^(www.)?domain.org$
RewriteCond %{REQUEST_URI} !^/drupalbeta/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /drupalbeta/$1
RewriteCond %{HTTP_HOST} ^(www.)?domain.org$
...
where Drupal installation lives in
/public_html/drupalbeta. And modify site settings.php:$base_url = 'http://www.domain.org'; // NO trailing slash!What I had incorrectly tried here was
...org/drupalbetarather than just the desired "base url" as shown above.And keep Drupal's .htaccess unmodified, so even RewriteBase remains commented and unused:
...# RewriteBase /
...
Hope this helps someone. See you at DrupalCamp Austin!
Same Problem
I was excited to find this post as I am struggling to make this work (same scenario). Unfortunately even after following these instructions I continue to have the subdirectory appended to the end of the host name. Starting to wonder if it's drupal that's doing it or my hosting service.
removing the subdirectory
I went round and round with this ... commenting out the lines
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
fixed it for me. New at this so I'm not sure if this disables something important.
lots of things
That should break most file serving and things like imagecache. Try going into your drupal directory and doing 'ln -sf www .' instead.
I haven't seen any problems
I haven't seen any problems on my site with those lines commented out, but, as noted in the initial post, the edited .htaccess file is outside the Drupal installation .... Drupal's htaccess remains unchanged.
Now whether there's a better way to do it -- without using the webroot htaccess -- I don't know.