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 want to redirect users from to This is the .htaccess file I have below, but I am not getting redirected to my new URL.

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^$ [NC]
    RewriteRule ^(.*)$ [L,R=301]

What am I missing?


share|improve this question
Are both and serving content out of the same directory? – Dave Drager Sep 29 '09 at 16:37
Yes, both and are being served from the same directory. – Tim Sep 29 '09 at 19:08

Try [R=301,L] instead of [L,R=301].

Note that the way you have it written, would match, but not

share|improve this answer
Hmm, no dice. I understand that I'm only matching on That's just the beginning test case. But I can't get that going. Basically, this is a subset of this issue: I figured I should tackle that in smaller pieces. – Tim Sep 29 '09 at 22:01

You're missing the escape of your regexp '.' character in the host name pattern for RewriteCond:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^uppereast\.com$ [NC]
    RewriteRule ^(.*)$ [L,R=301]


Also, the use of $ is not needed on the rule, all you need is:

RewriteRule ^(.*) [L,R=301]
share|improve this answer
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_HOST} ^uppereast\.com$ [NC] RewriteRule ^(.*) [L,R=301] <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_HOST} ^uppereast**.com$ [NC] RewriteRule ^(.*) [L,R=301] I tried both of these, but no dice. Could the apache segmentation faults have anything to do with this? – Tim Sep 30 '09 at 0:07
The segfault might (that ** in my comment above is this website screwing up, it was supposed to bold the \ character as an example to you only) be the source. The code snippet I gave above should work 100%, I use rewrite rules similar to this all the time to trap and redirect non-www URLS to their www. domain counterpart; many times they're more complex. Without escaping the '.' before com you're using a regexp pattern by mistake when you meant to match a single '.' character. Try turning on RewriteLog and RewriteLogLevel to capture the rewrite and discover the cause of your segfaults. – troyengel Oct 1 '09 at 19:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.