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 want to redirect users from http://uppereast.com to http://nyclocalliving.com. 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} ^uppereast.com$ [NC]
    RewriteRule ^(.*)$ http://nyclocalliving.com [L,R=301]
...

What am I missing?

Thanks

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

2 Answers 2

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

Note that the way you have it written, uppereast.com would match, but not www.uppereast.com.

share|improve this answer
    
Hmm, no dice. I understand that I'm only matching on uppereast.com. That's just the beginning test case. But I can't get that going. Basically, this is a subset of this issue: serverfault.com/questions/68838/broken-htaccess-modrewrite 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 ^(.*)$ http://nyclocalliving.com [L,R=301]
...

^uppereast*\*.com$

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

RewriteRule ^(.*) http://nyclocalliving.com [L,R=301]
share|improve this answer
    
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_HOST} ^uppereast\.com$ [NC] RewriteRule ^(.*) nyclocalliving.com [L,R=301] <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_HOST} ^uppereast**.com$ [NC] RewriteRule ^(.*) nyclocalliving.com [L,R=301] I tried both of these, but no dice. Could the apache segmentation faults have anything to do with this? serverfault.com/questions/68838/broken-htaccess-modrewrite –  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

 
discard

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