How to redirect a subdomain using the Registry DNS service.br

Asked

Viewed 3,015 times

1

I have a private server with fixed IP and I have some websites running on port 80.

Configuration: Debian Linux and Apache

For example, I have two subdomains:

IP_SERVIDOR/site1
IP_SERVIDOR/site2

I registered the two domains in the.br registry: "www.site1.com.br" and "www.site2.com.br".

I am using the DNS services of the.br record itself. I would like to know how I use the DNS Zone Edit to redirect each subdomain. That is to say:

www.site1.com.br -> IP_SERVIDOR/site1
www.site2.com.br -> IP_SERVIDOR/site2

The most I could do is set the type "A" in the DNS zone edition in the.br record.

Para o site1
www.site1.com.br    A    IP_SERVIDOR

Para o site2
www.site2.com.br    A    IP_SERVIDOR

That is, both sites will point to the root. In my case they will fall to the root of the folder www. I believe the rest of the configuration would be on the Apache server.

Could someone help me?

  • This setting is technology dependent. What server technology are you using?

  • Debian linux usage, apache server and websites are done in PHP. I’m a bit layabout networks and servers. I do not know, for example, if it is correct to call "/site1" and "/site2" subdomain.

1 answer

2


This implies changing the settings of the web server you use. In the case of apache, they are Virtualhosts.

Here is a link from the apache website, with instructions on how to proceed: http://httpd.apache.org/docs/2.2/vhosts/examples.html

In DNS configuration you only need one line, which associates the domain name with IP, type A. The rest can be configured on your server, from HTTP to email and other applications.

Regarding virtualhosts, it is necessary to create / edit the apache configuration file that has these settings, and put something similar to this (untested):

<VirtualHost *:80>
DocumentRoot /www/site1
ServerName www.site1.com.br
# Other directives here
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /www/site2
ServerName www.site2.com.br
# Other directives here
</VirtualHost>

Never forget security mechanisms in accessing files and other things to take into account when configuring a folder to root a website. The fact that in the examples there is a line that says "# Other Directives here", is because they should be!

  • I edited my question, I believe it is more complete.

  • 1

    @Alanvalejo the rest of the configuration is right in apache. the first example of the link I left in my reply serves the case.

  • Got it. I get a simpler setup just by including a . htaccess in the root of the www folder with some rules?

  • 1

    @Alanvalejo this is not related to . htaccess You can use . htaccess for other purposes, but the correct way to do this configuration is in apache.

  • I think the configuration by Virtualhost is very intuitive. I will try here.

  • I am unable to figure out which file to modify, in some places say to tinker with /etc/apache2/sites-available/ others /etc/apache2/sites-enable/ others in /etc/httpd/... and so on. Which file/place is right?

  • 1

    @Alanvalejo the existing file in /etc/apache2/sites-enabled by default is just a link to the /etc/apache2/sites-available. I think debian is in those folders and not in /etc/httpd, but checks the existence of the folders and the files.

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.