I have to domains pointing towards the same IP.

What I wish to do is:

When visited by domain_name1,make document_root:/usr/local/apache/htdocs1

when visited by domain_name2,make document_root:/usr/local/apache/htdocs2

how to get this done job?

(Note: this should certainly continue ServerFault)

What you would like to attain is called name-based virtual hosting.

Illustration of this in the recommended page:


NameVirtualHost *:80

<VirtualHost *:80>

ServerName www.domain.tld

ServerAlias domain.tld *.domain.tld

DocumentRoot /www/domain

</VirtualHost>

<VirtualHost *:80>

ServerName www.otherdomain.tld

DocumentRoot /www/otherdomain

</VirtualHost>

Using Virtual Hosts (samples)

NameVirtualHost *:80
<VirtualHost *:80>
    ServerName www.domain1.com
    DocumentRoot /usr/local/apache/htdocs1
</VirtualHost>
<VirtualHost *:80>
    ServerName www.domain2.com
    DocumentRoot /usr/local/apache/htdocs2
</VirtualHost>