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'm using a Apache2 server with Passenger for my Rails app.

I dunno how to create a 301 redirect in my VirtualHost as :

  • -->
  • -->

I've tried :

Redirect 301 /


Redirect permanent /

But it's not the way to do it :-)

Thx for your answers..

share|improve this question

migrated from Sep 12 '10 at 0:33

This question came from our site for professional and enthusiast programmers.

up vote 2 down vote accepted

Use mod_rewrite to do this. This article shows some examples, here's their way to rewrite non-www. to www.:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^domain\.com$
RewriteRule (.*)$1 [R=301,L]

For your purposes, I'd also extend this with the following:

RewriteCond %{HTTP_HOST} ^www.domain\.fr$
RewriteRule (.*)$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^domain\.fr$
RewriteRule (.*)$1 [R=301,L]

Of course, the last two could be combined with the proper regex modification in the RewriteCond. I'll leave this as an exercise for you, so you have an incentive to learn more about mod_rewrite. :-)

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.