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

2
  • Are both uppereast.com and nyclocalliving.com serving content out of the same directory? Sep 29, 2009 at 16:37
  • Yes, both uppereast.com and nyclocalliving.com are being served from the same directory.
    – Tim
    Sep 29, 2009 at 19:08

2 Answers 2

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.

1
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]
2
  • <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, 2009 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.
    – user15590
    Oct 1, 2009 at 19:41

You must log in to answer this question.