Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

237
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda