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 host 4 virtual hosts at a dedicated CentOS 5.6 server:

# rpm -qa|grep http
httpd-2.2.3-45.el5.centos.1

One of them is my Drupal 7.2 site and another was holding static texts and fotos belonging to my wife - here is the excerpt from httpd.conf:

<VirtualHost 85.214.19.116:80>
    DocumentRoot /var/www/html/preferans.de
    ServerName preferans.de
    ServerAlias preferans.de *.preferans.de
    ErrorLog logs/preferans.de/error_log
    CustomLog logs/preferans.de/access_log common
    <IfModule mod_rewrite.c>
        <Directory "/var/www/html/preferans.de">
            RewriteEngine on

            # needed by Drupal 7 for "clean URLs"
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_URI} !=/favicon.ico
            RewriteRule ^ index.php [L]
        </Directory>
    </IfModule>
</VirtualHost>

<VirtualHost 85.214.19.116:80>
    DocumentRoot /var/www/html/larissa-farber.de
    ServerName larissa-farber.de
    ServerAlias larissa-farber.de *.larissa-farber.de
    ErrorLog logs/larissa-farber.de/error_log
    CustomLog logs/larissa-farber.de/access_log common
</VirtualHost>

Now my wife has decided to move her files to Tumblr blog service.

As a quick measure I've put the following index.php into her dir:

# cat /var/www/html/larissa-farber.de/index.php
<?php
header('Location: http://larissa-farber.tumblr.com/');
?>

This works ok, but I'd rather use the mod_rewrite to do the redirect (that is - until I figure out how to transfer her web address to Tumblr completely, which should be possible too).

From reading the docs I understand, that I need something like:

RewriteRule ^(.*)$ http://larissa-farber.tumblr.com/$1 [R=301,L]

But where to put it and how to keep my other 3 virtual sites working?

Thank you! Alex

(This is not a promotion of any of the sites above, I'm just too lazy to use fake addresses here and don't see a reason for that).

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

You don't need mod_rewrite for such simple redirects. Use Redirect directive from mod_alias.

Place following into VirtualHost section with ServerName larissa-farber.de:

Redirect permanent / http://larissa-farber.tumblr.com/
share|improve this answer
    
This seems to work well, thank you, but: should I only replace the DocumentRoot line above? Or should I also get rid of the Server* and *Log lines in her VirtualHost section? –  Alexander Farber Jun 18 '11 at 14:06
    
You should keep at least ServerName and ServerAlias records or Apache won't be able to select appropriate VirtualHost section. –  AlexD Jun 18 '11 at 14:11
    
That's what I've thought too. Do you think ErrorLog makes any sense to keep there? –  Alexander Farber Jun 18 '11 at 14:17
    
I'd keep logs for a while just in case. –  AlexD Jun 18 '11 at 14:20
add comment

Your virtualhost host directive for your drupal site already has a mod_rewrite section, just duplicate that structure in the virtualhost for your other site. Alternatively you can place the mod_rewrite content in an .htaccess file in the web root of the specific virtual host you want to redirect.

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.