2

I apologize if this has been asked before, but I've looked at a number of questions here and none of them seem to answer my question.

I have a series of domains all pointing to my server. For each one I have set it's IP record and configured a VirtualHost in http.conf correctly as follows:

# example.com  
<VirtualHost *:80>  
    DocumentRoot /path/to/example
    ServerName example.com
    ServerAlias example.com
    ServerAlias www.example.com
</VirtualHost>

# other.com
<VirtualHost *:80>
    DocumentRoot /path/to/other
    ServerName other.com
    ServerAlias other.com
    ServerAlias www.other.com
</VirtualHost>

Now I have setup an IP on my server for test.other.com and I would like to redirect that to a completely other website: test.blogspot.com (because it moved).

I tried the following, but it redirects ALL websites to that website

# other.com
<VirtualHost *:80>
    ServerName test.other.com
    ServerAlias test.other.com
    Redirect / http://test.blogspot.com/
</VirtualHost>

I think it's because of the "/"? Not really sure. I tried VirtualHost test.other.com:80 but didn't work. I tried a bunch of things and didn't work, so I really need your help.

Thanks in advance.

1 Answer 1

3

You can do it with htaccess file, just create a couple modification are required. Make the sub domain have a proper directory:

<VirtualHost *:80>
ServerName test.other.com
ServerAlias test.other.com
DocumentRoot /path/to/directory
</VirtualHost>

Then create a .htaccess file in that directory with this content

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://newdomain.com/

Same can be written inside Apache site config, i just find it more easy to manage htaccess files.

1
  • BINGO! Thanks! I added the three lines inside the VirtualHost and it worked like a charm!
    – pek
    Jan 16, 2013 at 3:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .