You need to go to your DNS configuration (cloudflare, register.br, godaddy, dynadot) and add an alias to your subdomain within the existing domain DNS configuration.
Also, within the vhost configuration of your existing web server (apache, Nginx lighttpd and others), there should be an entry pointed root to the subdomain folder, usually this is created by Cpanel among other managers automatically.
This is a classic example of vhost from Nginx listening on port 80 which is the browser one. Note that the domain root folder is /var/www/html and that this template will be executed when there is a request that meets the defined server_names, in this case, www.meudominio.com and meudominio.with. Therefore the same vhost structure for your new subdomain (Subdomain.meudominio.com) pointing to your root folder should also exist on the server. Despite the different syntax the procedure is the same for apache and too.
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name www.meudominio.com meudominio.com;
location / {
try_files $uri $uri/ =404;
}
}
For example let’s say your domain is meudominio.with and you want to open the domain Domain.meudominio.com
Within the DNS settings you will see entries with these :
A meudominio.com 158.69.20.14
A www 158.69.20.14
That is www is a subdomain of meudominio.com and points to the ip of your server, in this case if we want to add a new subdomain, just add a new alias to your DNS, so:
A meudominio.com 158.69.20.14
A www 158.69.20.14
A subdominio 158.69.20.14
Saying that there is an alias (A) subdomain, which points to the ip of this machine as well or even using another server with a different ip. When someone makes a request by Domain.meudominio.com DNS resolution will forward the request to the ip pointed in your DNS record, arriving at the target server, the web server locates the vhost template with the requested server_name and meets the request by pointing to the internal folder defined in the root of your vhost file. Usually adding subdomains to your DNS does not require waiting time, since the main domain has already been propagated over the network.
You have access to Apache configuration files?
– Rytter
unfortunately not.. using the Hostinger s;
– Override_GER
Possible duplicate of How to force . htaccess to direct a domain into a folder?
– NoobSaibot
I still couldn’t make it work..
– Override_GER
sometimes even directs to the sub-domain, but ends up not taking the files from the directory..
– Override_GER
I have a project in codeigniter, within public_html, with an htacces for him.. and I have in this folder public_html another folder, which is another project all with the imports of code Igniter and a new . htaccess, this is what may give problem will be?
– Override_GER
I know how to do this only by editing the Apache configuration files, as you use the Hostinger hosting advise to contact them. The support boys are very attentive, it’s worth a try.
– Rytter