Question

Point domain to a subfolder

  • Posted on September 9, 2014
  • kirbyAsked by kirby

I have a Drupal install as a sub folder on a droplet. I want to point the domain to this subfolder, ie. 111.111.111.11/drupal. How do I do this within Digital Ocean’s control panel?

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi Kirby,

To be technically true, you can’t really “point a domain to a subfolder”, put you can point a domain to an IP, as required by DNS to go on a website using a domain name instead of its IP.

So, in your situation, I much advise you to use Nginx as a reverse proxy, thanks to the use of server_name directives and document root location.

For example, if you want to host many websites on your VPS at IP 111.111.111.11, you can create as many folders you want in /var/www folder, and configure all your nginx virtualhosts to point the correct folder.

tree /var/www/
├── drupal_1
├── drupal_2

Once you have the following tree in your document root, you can use server_name directives to separate your drupal instances relied to a domain name with Nginx, with a configuration file of that kind :

server {
  listen *:80;         
  server_name drupal_1; 
  root /var/www/drupal_1;

  location / {
    try_files $uri $uri/index.html $uri.html @upstream;
  }

  location @upstream {
   your php-fpm configuration
  }
}
server {
  listen *:80;         
  server_name drupal_2; 
  root /var/www/drupal_2;

  location / {
    try_files $uri $uri/index.html $uri.html @upstream;
  }

  location @upstream {
   your php-fpm configuration
  }
}

Thanks to that kind of Nginx configuration, I guess that you will be able to do what you are looking for,

Hope this could help,

Best regards,

– rustx

To expand rustx already detailed answer if you are not using Nginx the process is pretty similar in your domain manager/control panel simply point your AAAA record to your VPS IP Address and wait for it to refresh and start redirecting the domain to your VPS local folder than:

Open file: /etc/apache2/sites-enabled/000-default.conf

Or you can create a separate configuration file as you prefer I keep all my VHosts in one file. Once you have the configuration file open add new VHost configuration like so:

<VirtualHost *:80>
    DocumentRoot /var/www/subfolder
    ServerName www.domain.com
    ServerAlias domain.com
</VirtualHost>

Now go back to the folder: /etc/apache2 and open file: apache2.conf and add a new line:
ServerName www.domain.com

Save the file and restart your server using this command: service apache2 restart, the process is same across all OS the config folder locations tho can be different you can look those up.

@Joaobborges Setup your CNAME record to catch www too: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-host-name-with-digitalocean

(long tutorial, just scroll down to the CNAME section)