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

# rpm -qa|grep http

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:

    DocumentRoot /var/www/html/
    ServerAlias *
    ErrorLog logs/
    CustomLog logs/ common
    <IfModule mod_rewrite.c>
        <Directory "/var/www/html/">
            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]

    DocumentRoot /var/www/html/
    ServerAlias *
    ErrorLog logs/
    CustomLog logs/ common

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/

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 ^(.*)$$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
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

Redirect permanent /
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

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

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.