Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 staging.domain.com, but that currently doesn't work. The workaround that I've found to work is typing www.staging.domain.com. 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/staging.domain.com/public_html/index.php as the default file when I visit staging.domain.com.

As stated, I am currently only able to get what I want by visiting www.staging.domain.com. When I visit staging.domain.com I am redirected to www.staging.domain.com/staging.domain.com/public_html.

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

<VirtualHost *:80>
    # General Server Setup
    ServerAdmin admin@domain.com
    ServerName  www.staging.domain.com
    ServerAlias staging.domain.com

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

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.

Update

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       staging.domain.com        XX.XX.XX.XX(server IP)    300
 A       www.staging.domain.com    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
1  
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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.