WordPress Mod Rewrite Same Server

I’ve been researching this for got to be around 6 hours now (had I known I’d spend this long I would have read the manual from start to finish to learn things in-depth) and out of desperation I’m finally asking.

I have a client with two WordPress sites.

Read More

www.myoldsite.com and www.mynewsite.com.

www.myoldsite.com is hosted on a server I can’t access while I have access to www.mynewsite.com.

Because of this restraint I’ve decided to use a .htaccess file on www.mynewsite.com to handle specific 301 redirects and point the domain www.myoldsite.com to www.mynewsite. Most of the redirects are working without any issues but there are a few that aren’t. I know why but I can’t figure out how to fix it.

For example:
On the www.myoldsite.com they had the page www.myoldsite.com/about-us. 
On the new site the new URL is www.mynewsite.com/about-us/what-we-do.

The htaccess file looks like this:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^mynewsite.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mynewsite.com$
RewriteRule /about-us "http://mynewsite.com/about-us/what-we-do/" [R=301,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

At the moment this causes the recursive error “too many redirects”. If I change the Rewrite Rule to:

RewriteRule ^/about-us$ "http://mynewsite.com/about-us/what-we-do/" [R=301,L]

The URL www.myoldsite.com/about-us returns a 404 /index.php not found. This I can tell is coming from WordPress.

All I need www.myoldsite.com/about-us to point to www.mynewsite.com/about-us/what-we-do using a redirect. If anyone can assist that would be most helpful.

Thanks.

Related posts

Leave a Reply

1 comment

  1. Your RewriteRule is awfully long. I just successfully did the following with no fuss:

    RewriteRule ^about-us(/?)$ https://www.google.com/about/ [R=301,L]
    

    I think the forward-slash at the beginning of about-us in your rule is causing a problem.

    Also, I’m not 100% sure whether or not browsers cache these redirects, but I’ve had some trouble in the past with Firefox and 301 redirects where after a change Firefox’s behavior continued as before the change and opening a new browser (Safari) worked. You might check into that.