Where I config CNAME in VPS Server without Cpanel
You can't redirect a hostname to an URL with DNS (CNAME
record) alone.
There's plenty of things you need to know, but the correct path may be this (or something similar):
- You need to find out whether your VPS is the master name server for your domain. If it is:
-
Lets assume you have BIND. Your file location can be found from
/etc/bind/named.conf
(or any other config file included there, likenamed.conf.local
). There should be linezone "example.com" { type master; file "/etc/bind/db/example.com"; };
In the zone file found, you can start by adding
* IN CNAME example.com.
and updating serial in your@ IN SOA
to be in formatYYYYMMDDNN
with current date and order number.- Reload the changed zone file by command
rndc reload
. -
Add the redirect as
VirtualHost
on your Apache configuration (e.g. by adding new file in/etc/apache2/sites-available/subdomains.example.com
):<VirtualHost *:80> ServerName subdomains.example.com ServerAlias *.example.com Redirect / http://example.com/test </VirtualHost>
Enable site with
a2ensite subdomains.example.com
andservice apache2 reload
.
Whether the steps are exactly these or not, there will be all corresponding phases.