Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have a website (site1.com) that has another site being built within it (site1.com/newsite).

My client wants to create a new domain name and have it point to the directory that houses the new site.

As a front end dev I am very confused as to how to go about this. Is this something that can be in htaccess? What would I place on the registrars end?

Would anyone know the best way to do this?

share|improve this question

2 Answers 2

Let's assume that

  • your client's new domain is client.com

  • your server's ip address (where you have site1.com/newsite) is 192.168.1.1

  • the path to newsite on your server is /srv/www/newsite

  • your webserver is Apache

First, you need to create a virtual host in Apache, containing at least:

<VirtualHost *:80>
    DocumentRoot /srv/www/newsite
    ServerName www.client.com
    ServerAlias client.com
</VirtualHost>

If you're on Debian based systems, you can just create a new file clientsite.com in /etc/apache/sites-available and put that inside it.

Then run a2ensite client.com and service apache2 reload and you're done.

If you're not on Debian, look on how to add a vhost to your specific distribution apache (CPANEL also has a vhost section for Apache).

Now in your client's registrar, they need to point client.com and www.client.com to your server's ip address 192.168.1.1

Additional: as mentioned in the previous reply, you should prevent access to the /newsite dir so people can only access it by the client.com address, and not by site1.com/newsite. To do that, in your site1.com vhost, put this

<Directory "/newsite">
  Deny from all
</Directory>

Update the question with more information (include at your OS and webserver and if you have CPANEL or anything similar). The more precise your question is, the more precise the replies you get will be.

share|improve this answer

If you have access to your current hosting setup, you can configure a new virtual host for the domain in your web server.

You would point the root directory of that virtual host to the newsite directory.

Then, you would just enter the IP address of your current web server as the new domain's A records.

You might also want to exclude access to the newsite directory via the old site with .htaccess rules.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.