0

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

Dave Drager
  • 8,375
  • 29
  • 45

2 Answers2

1

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.

Dave Drager
  • 8,375
  • 29
  • 45
  • Hmm, no dice. I understand that I'm only matching on http://uppereast.com. That's just the beginning test case. But I can't get that going. Basically, this is a subset of this issue: http://serverfault.com/questions/68838/broken-htaccess-modrewrite I figured I should tackle that in smaller pieces. –  Sep 29 '09 at 22:01
0

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]
  • RewriteEngine on RewriteCond %{HTTP_HOST} ^uppereast\.com$ [NC] RewriteRule ^(.*) http://nyclocalliving.com [L,R=301] RewriteEngine on RewriteCond %{HTTP_HOST} ^uppereast*\*.com$ [NC] RewriteRule ^(.*) http://nyclocalliving.com [L,R=301] I tried both of these, but no dice. Could the apache segmentation faults have anything to do with this? http://serverfault.com/questions/68838/broken-htaccess-modrewrite –  Sep 30 '09 at 00: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. –  Oct 01 '09 at 19:41