htacces rewrite condition old site to new site with querystring

Posted by Brandon Braner on Server Fault See other posts from Server Fault or by Brandon Braner
Published on 2013-10-17T15:05:04Z Indexed on 2013/10/17 16:03 UTC
Read the original article Hit count: 175

I am not even going to pretend to fully understand how htaccess rewrite conidtions work. Ive been working on this for a while searching and searching.

I have an old wordpress site www.old-site.com and a new site www.site.com wordpress uses query strings page_id=# to redirect to pages

on the old site page_id=2 went to a specific page but on the new site it goes the the home page

i need old-site/?page_id=2 to go to site.com/our-company here is what i am trying

RewriteCond %{HTTP_HOST} ^(www.)?old-site.com$ [NC] RewriteCond %{QUERY_STRING} ^page_id=2$ RewriteRule ^(.*)$ http://www.site.com/our-company/ [R=301,L]

if i take out the rewrite conditio for query string it redirects all traffic from old-site.com to the our company page on the new site. where am i going wrong?

i have about 15 redirects i need to do this way.

thanks in advance

© Server Fault or respective owner

Related posts about .htaccess

Related posts about mod-rewrite