Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

225
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!