I tried multiple tutorials online but up to no avail.
I want to point my new domain (eg newdomain.com
) to a folder in /var/www/html/new/
.
I bought the domain off namecheap.com and have set the custom DNS to dns1-3.digitalocean.com. Next, I made the DNS changes in the Networking area in the control panel. https://i.imgur.com/9tbsT4C.png
Afterwards, I created a Apache’s VirtualHost in /etc/apacheites-available
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/mew
ServerAlias newdomain.com
ServerName newdomain.com
<Directory /var/www/html/new>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
Require all granted
</Directory>
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://IP-ADDRESS/new/ Keepalive=On
ProxyPassReverse / http://IP-ADDRESS/new/
ProxyPreserveHost On
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
After restarting Apache2, my primary + new domain doesn’t seem to be loading at all.
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.
@SprX
You don’t need the ProxyPass configuration unless you’re passing the request over to an address that uses a port other than 80/443. For example, if you were running a NodeJS app that was running on a port such as 2365, and you wanted it to respond on a port 80 (i.e. without having to attach a port to the URL), then you would use ProxyPass.
For a standard domain setup, you really only need
So if that’s your base and you want
domain02.com
to point to/new
in the same directory as your existing domain, you’d setup another server block and use something such as: