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).
You don't need
mod_rewrite
for such simple redirects. Use Redirect directive frommod_alias
.Place following into
VirtualHost
section withServerName larissa-farber.de
: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.