0

I am not even going to pretend to fully understand how htaccess rewrite conditions work. I've 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 condition for query string it redirects all traffic from old-site.com to the company page on the new site. Where am I going wrong?

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

MadHatter
  • 78,442
  • 20
  • 178
  • 229
  • Have you enabled rewritelog? If not, start by doing that. Usually the problem is due to something you are trying to match not being what you expect it to be. The rewritelog will tell you exactly what is being matched against what. – Krist van Besien Oct 22 '13 at 06:09
  • Your problem is btw, a good candidate for a rewrite map: http://serverfault.com/a/496796/163704 – Krist van Besien Oct 22 '13 at 06:12

1 Answers1

0

fyi answered my own question

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

without the ? after the new url it apends the query string to the end of it adding ? ends the line there

ill look into this rewrite map thanks

KM.
  • 1,746
  • 2
  • 18
  • 31