Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to set up a staging server to run as a sub-domain of my production server and I'm running into a small problem.

I have my production server hosted on a RackSpace virtual machine. I cloned this machine to use as my staging server. I also added A records to direct the sub-domain address to this new virtual machine.

I want to be able to access this staging server by typing, but that currently doesn't work. The workaround that I've found to work is typing Note the extra www in front of the sub-domain.

My directory structure is such that in my project directory I have a public_html directory (which obviously houses the publicly viewable files) and a private (which houses more of the back-end code). I want to have Apache serve /var/www/ as the default file when I visit

As stated, I am currently only able to get what I want by visiting When I visit I am redirected to

My httpd.conf is set up as follows (I am definitely not an expert in configuration of this file):

<VirtualHost *:80>
    # General Server Setup

    # Indexes + Directory Root
    DirectoryIndex index.php index.html
    DocumentRoot /var/www/
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            Allow from all

I am pretty sure that the redirect I spoke of earlier is happening because of my specified DocumentRoot in this file.

Also, I have tried many different combinations of CNAME and A records trying to get this to work, but I'm open to any other suggestions you might have.


I don't have anything specified for my .htaccess file, so that shouldn't be effecting anything.

My current DNS record for this server are:

Type    Name                      Content                   TTL
 A        XX.XX.XX.XX(server IP)    300
 A    XX.XX.XX.XX(server IP)    300

There is really no additional information that I've configured that I can think of to share with you. If you can think of anything just ask.

share|improve this question
At least from the config that you've shown us, Apache isn't doing that redirect. Check your code? – Shane Madden Nov 22 '11 at 15:52
@ShaneMadden I have added some new information. As far as your statement about Apache, the code is copied verbatim (minus the domain name of course). – ServAce85 Nov 22 '11 at 16:07
As far as "code" I mean your php code. Unless there's some config outside of that VirtualHost, then Apache isn't the cause of that redirect. Though now that I think about it, check /var/www for an .htaccess file. – Shane Madden Nov 22 '11 at 16:13
@ShaneMadden +1 for being awesome. /var/www/.htaccess was the problem. Thanks! – ServAce85 Nov 22 '11 at 16:22
up vote 0 down vote accepted

It turns out that there was a default .htaccess file in the /var/www/ directory that was causing this action. I removed it as suggested by @Shane_Madden which fixed the problem.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.