Question

How to edit htaccess so that domain x is resolved by server-root and domain y by subdirectory

Asked by: TheoRichel

The CMS Drupal has an option where one can serve multiple domains frome one codebase. I have the following configuration

www.richel.org answered by www.richel.org/index.html
www.baszeeland.org, now answered by www.richel.org/index.html

But I want www.baszeeland.org to be answered, resolved, by www.richel.org/drupal  (where there is a directory with the name www.baszeeland.org )

It is suggested that this can be done by just editing the Drupal htaccess but I do not get clear answers on that, maybe I should edit root htaccess as wel.

Fyi I put below the contents of the drupal htaccess and below that the root htaccess. Thanks in advance.
-------------------------------
#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.
<FilesMatch "(\.(engine|inc|install|module|sh|.*sql|theme|tpl(\.php)?|xtmpl)|code-style\.pl|Entries.*|Repository|Root)$">
  Order deny,allow
  Deny from all
</FilesMatch>

# Set some options.
Options -Indexes
Options +FollowSymLinks

# Customized error messages.
ErrorDocument 404 /index.php

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.

# PHP 4, Apache 1
<IfModule mod_php4.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
</IfModule>

# PHP 4, Apache 2
<IfModule sapi_apache2.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
</IfModule>

# PHP 5, Apache 1 and 2
<IfModule mod_php5.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
</IfModule>

# Reduce the time dynamically generated pages are cache-able.
<IfModule mod_expires.c>
  ExpiresByType text/html A1
</IfModule>

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on

 #
   # If you want the site to be accessed WITH the www. only, adapt and
   # uncomment the following:
-  # RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
+  # RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
   # RewriteRule .* http://www.example.com/ [L,R=301]
   #
   # If you want the site to be accessed only WITHOUT the www. prefix, adapt
   # and uncomment the following:
-  # RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
+  # RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
   # RewriteRule .* http://example.com/ [L,R=301]
 
  # Modify the RewriteBase if you are using Drupal in a subdirectory and
  # the rewrite rules are not working properly.
  # RewriteBase /drupal

  # Rewrite old-style URLs of the form 'node.php?id=x'.
  #RewriteCond %{REQUEST_FILENAME} !-f
  #RewriteCond %{REQUEST_FILENAME} !-d
  #RewriteCond %{QUERY_STRING} ^id=([^&]+)$
  #RewriteRule node.php index.php?q=node/view/%1 [L]

  # Rewrite old-style URLs of the form 'module.php?mod=x'.
  #RewriteCond %{REQUEST_FILENAME} !-f
  #RewriteCond %{REQUEST_FILENAME} !-d
  #RewriteCond %{QUERY_STRING} ^mod=([^&]+)$
  #RewriteRule module.php index.php?q=%1 [L]

  # Rewrite current-style URLs of the form 'index.php?q=x'.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>

DocumentRoot /home/virtual/richel.org/var/www/html/drupal

# $Id: .htaccess,v 1.73 2006/04/14 09:08:26 killes Exp $
-----------------------------

Contens root access

AddType application/x-httpd-cgi .cgi
Options +ExecCGI
DirectoryIndex index.cgi index.html index.htm index.php

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2006-09-20 at 03:29:12ID21995954
Tags

htaccess

,

documentroot

,

allowed

Topic

Web Servers

Participating Experts
1
Points
500
Comments
28

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Apache and htaccess files
    I have just installed the latest version of Apache. I wanted to test out the htaccess capability of the server so I created a directory called foo, which is under the htdocs directory. For some reason it looks like Apache just ignores the htaccess file and displays the inde...
  2. .htaccess in cgi-bin
    i have a .htaccess file in my htdocs/protected dir and it works fine (i am asked for a password from the .htpasswd file when i request the data in that dir via my browser) but when i put the exact same .htaccess file into my cgi-bin/protected dir it wont work! any ideas wh...
  3. .htaccess
    I´m using .htaccess to protect my site, but I belive it´s been hacked. I have total deny of any entry to either .htaccess and .htpasswd... Is there any bug in .htaccess that I´m not aware of?

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: ahoffmannPosted on 2006-09-20 at 04:04:41ID: 17559477

> But I want www.baszeeland.org to be answered, resolved, by www.richel.org/drupal  (where there is a directory with the name www.baszeeland.org )

RewriteCond %{HTTP_HOST} ^www\.baszeeland\.org$
RewriteRule .* http://www.richel.org/drupal [L,R=301]

# feel free to adjust the L and R flag as xou like

 

by: TheoRichelPosted on 2006-09-20 at 04:22:58ID: 17559651

Thank you, but so far no success.

I have pasted the two lines you gave me in the Drupal htaccess, just before </IfModule> and then nothing changed: page not found when I gave in www.baszeeland.org

When I pasted the two lines in root htaccess then my whole site became forbidden. I do not know whether I should have added Rewrite Engine on-type lines as well.
And does the line *DocumentRoot /home/virtual/richel.org/var/www/html/drupal*  in Drupal htaccess have any effect?

So please try again.

Thanks

 

by: ahoffmannPosted on 2006-09-20 at 04:49:26ID: 17559799

as you're redirecting virtual hosts, this change have to be done in apache's httpd.conf, followed by a server restart
Don't know how drupal includes "your" htaccess, but it requires a restart, if not already configured that www.baszeeland.org redirects to www.richel.org

 

by: TheoRichelPosted on 2006-09-20 at 04:59:40ID: 17559862

My webhost doesnt give me access to httpd.conf and refuses to edit that file. They say: 'all this can be done with htaccess, but telling you how is outside the realm of our support.'

 

by: TheoRichelPosted on 2006-09-20 at 08:28:07ID: 17561622

www.baszeeland.org is parked on www.richel.org does that change anything?

 

by: ahoffmannPosted on 2006-09-21 at 01:33:23ID: 17567365

as long as DNS points to the same IP, you most likely have a name-based virtual host in apache, which requires that redirects are done in httpd.conf and not a .htaccess found in a directory.

It might work if DocumentRoot for both domains is the same and contains your .htaccess.

 

by: TheoRichelPosted on 2006-09-21 at 02:02:42ID: 17567494

Allright and what would be the contents of such a .htaccess file?
Now my root .htaccess- contain only this:
 ----------------
AddType application/x-httpd-cgi .cgi
Options +ExecCGI
DirectoryIndex index.cgi index.html index.htm index.php
------------------
Documentroot for Drupal is:
DocumentRoot /home/virtual/richel.org/var/www/html/drupal

Thanks

 

by: ahoffmannPosted on 2006-09-21 at 02:19:40ID: 17567575

Rewrite* directives as explained in my first comment

but when I look at your question and the previous comment, I'd remind that you check if you really have
   /home/virtual/richel.org/var/www/html/drupal/drupal
otherwise you get an 40x not found

 

by: TheoRichelPosted on 2006-09-21 at 02:24:22ID: 17567592

I do not understand Rewrite-asterisk. Just paste this in the htaccess I presume:

RewriteCond %{HTTP_HOST} ^www\.baszeeland\.org$
RewriteRule .* http://www.richel.org/drupal [L,R=301]

Amd re the root: that is what my host told me. I first thought it would be /var/www/html/drupal

 

by: ahoffmannPosted on 2006-09-21 at 03:38:01ID: 17567828

while I don't get used to your problem (is there still one?), you seem to have problems writing a .htaccess as suggested. Try following as you .htacsess (excluding the ----------------- lines):

-----------------
AddType application/x-httpd-cgi .cgi
Options +ExecCGI
DirectoryIndex index.cgi index.html index.htm index.php

Documentroot for Drupal is:
DocumentRoot /home/virtual/richel.org/var/www/html/drupal
RewriteCond %{HTTP_HOST} ^www\.baszeeland\.org$
RewriteRule .* http://www.richel.org/
-----------------


if it does not do what you want, then please post corresponding messages from your error_log *and* access_log. Also post the result of:

  ls -la /home/virtual/richel.org/var/www/html/drupal

 

by: TheoRichelPosted on 2006-09-21 at 03:59:25ID: 17567923

Did as you said and got the message below. Also other domains on server are unavailable now. Will try to get error server log. I do not understand what you mean by 'the result of:   ls -la /home/virtual/richel.org/var/www/html/drupal '

------------------
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, blackhole@ensim.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Apache/1.3.27 Server at www.richel.org Port 80

--------------------------------------------------------------------------------

 

by: TheoRichelPosted on 2006-09-21 at 04:23:47ID: 17568071

From my access log, the only line about Baszeeland: [20/Sep/2006:16:48:28 -0400] "GET /drupal/sites/www.baszeeland.org HTTP/1.0" 500 598 "-" "

Error log has no references to baszeeland.

Thanks

 

by: ahoffmannPosted on 2006-09-21 at 05:53:48ID: 17568588

> Error log has no references to baszeeland.
.. and your access_log also has no reference? then the request never reached the server, or the server is totally misconfigured

 

by: TheoRichelPosted on 2006-09-21 at 07:01:02ID: 17569158

Well my access log had a ref to baszeeland and it gave error code 500 - 598. I cannot find the meaning of 598 though. Well we are going to call it quits. I am impressed by your qualfications and convinced that if you cant make this work then I do not know who can. I have found another webhost (specialised in Drupal) end it worked right away (no of course not wrt the domain name, we're awaitiong the dns switch for that.

I do not know whether totally misconfigured is an apt description for my current host, but there certainly are a lot of problems there.

So thanks for your comments and take the points.

 

by: TheoRichelPosted on 2006-09-21 at 07:02:29ID: 17569167

I am reluctant to push the accept button, because this obviously is not a solved problem. Tell me if I should push it and I will.

Thanks
TR

 

by: ahoffmannPosted on 2006-09-21 at 09:25:12ID: 17570669

I'd like to get it working, even without knowing what's going on
But you can hit the accept button as you like ;-)

Back to the problem:
  please post the entries from access_log *and* error_log you get when you call following links:

   http://www.richel.org/index.html
   http://www.baszeeland.org/index.html
   http://www.richel.org/noneexistant
   http://www.baszeeland.org/noneexistant

you should get at least 2 messages in access_log and 2 in error_log

 

by: TheoRichelPosted on 2006-09-21 at 10:41:39ID: 17571426

In access log I get 2 refs to index.html and also to noneexistant. These are the lines:

[21/Sep/2006:12:59:13 -0400] "GET /index.html HTTP/1.0" 200 1016 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1)"
cable-201-176.zeelandnet.nl - -
[21/Sep/2006:12:59:41 -0400] "GET /index.html HTTP/1.0" 304 - "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1)"
lj601110.inktomisearch.com - - [21/Sep/2006:12:59:45 -0400] "GET /querulant/ HTTP/1.0" 304 - "-" "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)"
cable-201-176.zeelandnet.nl - -
[21/Sep/2006:12:59:55 -0400] "GET /noneexistant HTTP/1.0" 404 277 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1)"
cable-201-176.zeelandnet.nl - -
[21/Sep/2006:13:00:09 -0400] "GET /noneexistant HTTP/1.0" 404 277 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1)"
lj602334.inktomisearch.com - -


The error log follows in the next post

 

by: TheoRichelPosted on 2006-09-21 at 10:45:17ID: 17571455

These are the 2 lines of nonexistant in the error log

[Thu Sep 21 12:59:55 2006] [error] [client 82.176.201.176] File does not exist: /home/virtual/site407/fst/var/www/html/noneexistant

[Thu Sep 21 13:00:09 2006] [error] [client 82.176.201.176] File does not exist: /home/virtual/site407/fst/var/www/html/noneexistant


The two indel.html url's were there so no errors.

 

by: ahoffmannPosted on 2006-09-21 at 10:49:55ID: 17571496

I guess you checked the error_log from  www.richel.org, then your Rewrite rules in .htaccess do not get used.

Also, the path in th errro_log does not match the path of DocumentRoot you posted here. Is this due to soft links or mount points. Could you please explain.

 

by: TheoRichelPosted on 2006-09-21 at 11:01:39ID: 17571599

The domain baszeeland.org is parked upon richel.org

I am affraid I do not know what softlinks or mount points are

 

by: TheoRichelPosted on 2006-09-21 at 11:08:55ID: 17571662

I have put the following hopefully correct documentRoot in htaccess:

Documentroot for Drupal is:
DocumentRoot /home/virtual/site407/fst/var/www/html/drupal
RewriteCond %{HTTP_HOST} ^www\.baszeeland\.org$
RewriteRule .* http://www.richel.org/


But still no luck: Internal Sever Error, all domains

 

by: ahoffmannPosted on 2006-09-21 at 13:24:07ID: 17572656

>  I have put the following hopefully correct documentRoot in htaccess:
if you cant figure out yourself what the real path is, you need to ask the admins which path you must use for DocumentRoot. DocumentRoot is a core configuration, if it is wrong most things will not work.

 

by: TheoRichelPosted on 2006-09-23 at 06:44:11ID: 17583618

The admins have confirmed, below is my documentroot.

/home/virtual/site407/fst/var/www/html

Thanks

 

by: ahoffmannPosted on 2006-09-23 at 09:56:33ID: 17584024

did you  use it this way in your .htaccess?

 

by: TheoRichelPosted on 2006-09-23 at 10:13:46ID: 17584073

yes sure. got the message: internal server error 500 and entire server (also other domains) unavailable.

 

by: ahoffmannPosted on 2006-09-23 at 12:57:35ID: 17584485

each error leaves a message in error_log, how about posting that?

 

by: TheoRichelPosted on 2006-09-24 at 02:36:15ID: 17586027

From the error log:

/home/virtual/site407/fst/var/www/html/robots.txt
[Sun Sep 24 05:20:42 2006] [error] [client 82.176.201.176] File does not exist: /home/virtual/site407/fst/var/www/html/www.richel.org/drupal
[Sun Sep 24 05:27:23 2006] [alert] [client 82.176.201.176] /home/virtual/site407/fst/var/www/html/.htaccess: DocumentRoot not allowed here
[Sun Sep 24 05:27:24 2006] [alert] [client 80.200.15.49] /home/virtual/site407/fst/var/www/html/.htaccess: DocumentRoot not allowed here
[Sun Sep 24 05:27:28 2006] [alert] [client 80.200.15.49] /home/virtual/site407/fst/var/www/html/.htaccess: DocumentRoot not allowed here
[Sun Sep 24 05:27:33 2006] [alert] [client 80.200.15.49] /home/virtual/site407/fst/var/www/html/.htaccess: DocumentRoot not allowed here
[Sun Sep 24 05:27:35 2006] [alert] [client 82.176.201.176] /home/virtual/site407/fst/var/www/html/.htaccess: DocumentRoot not allowed here
[Sun Sep 24 05:27:39 2006] [alert] [client 80.200.15.49] /home/virtual/site407/fst/var/www/html/.htaccess: DocumentRoot not allowed here
[Sun Sep 24 05:27:43 2006] [alert] [client 82.176.201.176] /home/virtual/site407/fst/var/www/html/.htaccess: DocumentRoot not allowed here
[Sun Sep 24 05:27:45 2006] [alert] [client 80.200.15.49] /home/virtual/site407/fst/var/www/html/.htaccess: DocumentRoot not allowed here
[Sun Sep 24 05:27:45 2006] [alert] [client 80.58.205.34] /home/virtual/site407/fst/var/www/html/.htaccess: DocumentRoot not allowed here
[Sun Sep 24 05:27:50 2006] [alert] [client 80.200.15.49] /home/virtual/site407/fst/var/www/html/.htaccess: DocumentRoot not allowed here
[Sun Sep 24 05:27:54 2006] [alert] [client 83.202.124.197] /home/virtual/site407/fst/var/www/html/.htaccess: DocumentRoot not allowed here
[Sun Sep 24 05:28:17 2006] [error] [client 200.65.127.163] unrecognized FrontPage request: /home/virtual/site407/fst/var/www/html/querulant/Onbespoten

 

by: ahoffmannPosted on 2006-09-24 at 12:07:50ID: 17587935

> ... .htaccess: DocumentRoot not allowed here
and in http:#17559862
> My webhost doesnt give me access to httpd.conf and refuses to edit that file. They say: 'all this can be done with htaccess, but telling you how is outside the realm of our support.'

either you did not follow what they told you to do, or it's time to get rid of that hoster

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...