Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

227
Visualizações
Apache 2 how to set multiple websites with the same domain?

I have one domain: example.com, and I need to have 2 different sites with this domain like I explain below.

Site 1: example.com

Site 2: example.com/site2

I tried to do a virtual host for each site, I show below:

Site 1 virtual host:

<VirtualHost *:80>

ServerAdmin webmaster@localhost
ServerName example.com
DocumentRoot /var/www/html/site1/

<Directory /var/www/html/site1>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted

</Directory>

</VirtualHost>

Site 2:

ServerAdmin webmaster@localhost
ServerName example.com/site2
DocumentRoot /var/www/html/site2/

<Directory /var/www/html/site2>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted

</Directory>

</VirtualHost>

However it's not working, when I type example.com it redirects me to example.com/site2 but it's showing page not found, like trying to search the page /site2 under example.com, I need it to be 2 separated websites.

Hope someone can help me. I'm using wordpress and magento for the sites. example.com has Magento 2 and example.com/site2 has wordpress

Thanks!

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

A domain name cannot have slashes, information that starts with a slash begins the path section of the URL, which navigates down the website tree.

If you have two sites under the same domain name, the proper way to handle this is through subdomains. In your example that would be:

example.com
site2.example.com

You would need to update your DNS record for the domain, in this example, in the example.com's domain record, there would need to be a new A record for site2.

Then on Apache, what you are doing is fine, you would just need to change site2's ServerName:

ServerName site2.example.com
DocumentRoot /var/www/html/site2/

These two sites do not need to be in the same file structure (they don't even need to be on the same server).

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda