I have my development environment installed on my workstation at the following directory location:
C:\www\projects\foobar
The sites folder I use for this localhost environment is named "localhost.foobar.com".
In my HOSTs file, I have "127.0.0.1 localhost.foobar.com".
In the .HTACCESS file in C:\www, I have the following:
RewriteEngine On
RewriteBase /
# localhost.foobar.com...
RewriteCond %{HTTP_HOST} ^localhost\.foobar\.com$ [NC]
RewriteRule ^$ projects/foobar/index.php [L]
RewriteCond %{HTTP_HOST} ^localhost\.foobar\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/projects/foobar%{REQUEST_URI} -f
RewriteRule .* projects/foobar/$0 [L]The problem I'm having is when I log into my localhost.foobar.com development site. I log in and *poof*, I'm back at web root in the browser (which is basically "http://localhost" but due to the HOSTs entry and the domain I use in the browser, shows up as "http://localhost.foobar.com/home").
I know this is due to the .HTACCESS + site configuration but I'm not sure what specifically needs to be changed. I'm trying to set this all up to accommodate for other project installs, so it would be nice if I could do something like follows:
RewriteCond %{HTTP_HOST} ^localhost\.project1\.com$ [NC]
RewriteRule ^$ <Request Result>
RewriteCond %{HTTP_HOST} ^localhost\.project2\.com$ [NC]
RewriteRule ^$ <Request Result>
RewriteCond %{HTTP_HOST} ^localhost\.project3\.com$ [NC]
RewriteRule ^$ <Request Result>
...Any ideas how to do this?
Comments
So why don't you use drupal's
So why don't you use drupal's shipped .htaccess files?!?
Did i answer your question on the forums? I love to hear a reply wether or not it worked for you!
Jaap - Acquia certified drupal site builder
I am. The .HTACCESS file that
I am. The .HTACCESS file that's causing the problems is the one in my web root, not the respective Drupal installation.
My web server web root starts at C:\www. The Drupal installation itself that I'm working on is found in C:\www\projects\foobar. The .HTACCESS at web root is causing the problems here (or at least I believe it is up to this point). Does that make sense? Basically, I'm just trying to have various Drupal projects in 1 web server (i.e. - "C:\www\projects\foobar1," C:\www\projects\foobar2," etc.) but due to how some Drupal implementations use multiple environment configurations in their *sites* folder, it makes setting this up a bit difficult.
Maybe you don't need a
Maybe you don't need a .htaccess in your web root at all? As far as i know, you can actually install drupal in a sub folder.
Maybe the easiest solution for you would be to do a multi site installation in the webroot. You'd only have to assign a FQDN using either your hosts file or DNS.
Alternatively, you can configure apache to use virtual hosts. That will give you a clean root for each site. It's a bit more cumbersome to maintain however. (if you ever find a way to quickly add/remove virtual hosts and update hosts file on dev machine, let me know!).
Did i answer your question on the forums? I love to hear a reply wether or not it worked for you!
Jaap - Acquia certified drupal site builder
Maybe I didn't explain the
Maybe I didn't explain the configuration well enough to illustrate the environment I'm working on but what I'm trying to do is accommodate for installations of *any kind* from within my server's web root--not just Drupal, the Drupal web root, etc. This is about setting up an effective development environment--not an effective Drupal installation. So having a multi-site implementation at web root won't work here because that would be setting up the web root for Drupal alone. (But bear in mind that you're close to the proper solution via your idea about using the multi-site architecture--more about this below). Also, there's no need for virtual hosts with all this, either (though it's not necessarily a bad idea, I guess). Extra overhead is added by using virtual hosts when all I need is a healthy HTACCESS.
Anyway, I got everything to work. What it turned out to be was a combination of HTACCESS issues as well as forgetting to set the $base_url value in the respective Drupal installations.
Here's what I did:
Webroot HTACCESS (not the Drupal web root but the *entire server* web root) -
$base_urls corresponding to each Drupal installation -
Once I did everything above, it began to behave as expected. Just remember that the web root HTACCESS and Drupal $base_url variable go hand-in-hand. If you add a Drupal install, you add an HTACCESS entry for it. :)
Quickly add/remove virtual hosts
This is a response to babipanghang (and for future reference).
I have a blog post that addresses the virtual hosts issue. You can check it out at http://drupaland.eu/article/apache-virtual-hosts.