Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8997005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:49:48+00:00 2026-06-15T23:49:48+00:00

This has probably been asked but I can’t find a straight answer, or the

  • 0

This has probably been asked but I can’t find a straight answer, or the ones I found don’t work.

I have one domain mydomain.com, resolving to an IP; let’s call it 8.8.8.8. The DNS settings also point two subdomains to that IP address with an A record. These are dev.mydomain.com and staging.mydomain.com. Both have an A-record pointing to 8.8.8.8.

On the server (8.8.8.8) I have two virtual hosts files. These are as follows:

staging.mydomain.com.conf

<VirtualHost *:80>
    ServerName  staging.mydomain.com
    DocumentRoot /var/www/html/mydomain.com/staging/
</VirtualHost>

And…

dev.mydomain.com.conf

<VirtualHost *:80>
    ServerName  dev.mydomain.com
    DocumentRoot /var/www/html/mydomain.com/dev/
</VirtualHost>

The problem is:

Regardless of whether I visit http://staging.mydomain.com or http://dev.mydomain.com, I always land on staging.mydomain.com (Apache serves these files).

I have restarted Apache and even the server. If I change the order of the .conf files so that dev is first, I always see that. Any suggestions would be so appreciated. Thanks!


update

I find myself back at this problem again! If you know that your syntax is correct, you might have a bad symlink. Delete it and recreate again, restarting apache in-between. I just did this and it solved hours of head-scratching. On CentOS you can check your available vhosts with httpd -S

update 2

I’ve also found this issue to exist when the apache log files for the virtual host don’t exist, or aren’t writable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:49:49+00:00Added an answer on June 15, 2026 at 11:49 pm

    Sounds like you need to add NameVirtualHost directive to your configuration.

    NameVirtualHost         *:80
    

    Under some circumstances Apache may not be able to handle *:80 VirtualHosts correctly. In those cases you should map VirtualHosts directly on specific IPs.

    NameVirtualHost         8.8.8.8:80
    
    <VirtualHost 8.8.8.8:80>
        ServerName  staging.mydomain.com
        ServerAlias stage.mydomain.com
        DocumentRoot /var/www/html/mydomain.com/staging/
    </VirtualHost>
    
    <VirtualHost 8.8.8.8:80>
        ServerName  dev.mydomain.com
        ServerAlias development.mydomain.com
        DocumentRoot /var/www/html/mydomain.com/dev/
    </VirtualHost>
    

    You can also run apachectl -t -D DUMP_VHOSTS to see how Apache parses the VirtualHost configuration.

    Update: As mentioned in the comments, usually you can just use NameVirtualHost *:80. So most of the time you can configure the virtual hosts as follows.

    NameVirtualHost         *:80
    
    <VirtualHost *:80>
        ServerName  staging.mydomain.com
        ServerAlias stage.mydomain.com
        DocumentRoot /var/www/html/mydomain.com/staging/
    </VirtualHost>
    
    <VirtualHost *:80>
        ServerName  dev.mydomain.com
        ServerAlias development.mydomain.com
        DocumentRoot /var/www/html/mydomain.com/dev/
    </VirtualHost>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This has probably been asked before but I can't seem to find the answer.
This has probably been asked, but I can't find it... I want to link
This has probably been asked before, but I can't find a good way of
I know this has probably been asked before, but I can't find it with
This probably has been asked before but all I can find are questions regarding
I know this has probably been asked before but I can't find a specific
This has probably been asked before but I can't find it anywhere. I have
I know this has probably been asked before but I can't seem to find
This has probably been asked somewhere but I can't find it for the life
This has probably been asked before but I can't find any relevant post using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.