I read all the other similar questions, but could not understand how to set it up so my old pages redirect where they should.
Here is my set up:
My old site pages:
http://www.oldsite.com/blog/?p=1234
http://www.oldsite.com/blog/?p=432
http://www.oldsite.com/blog/?p=xxxx
I would like to redirect the first two like so:
http://www.oldsite.com/blog/?p=1234 -> http://www.newsite.com/somewhere/on/mysite/
http://www.oldsite.com/blog/?p=432 -> http://www.newsite.com/somewhere/else/on/mysite/
and have all other pages (123, 321, 567, 999, ...) redirect to my home page like so:
http://www.oldsite.com/blog/?p=***** -> http://www.newsite.com/
Thanks in advance!
I tried @Jon Lin code, but it did not work for my WordPress site. I think the problem was that I am running WordPress... I should have included my .htaccess code, but I was not thinking that WP would be the problem...
Here is what I had to do in order to make it work: Because it is WP site you need to put the code in the WP mod_rewrite. Here is my .htaccess before the redirects:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
and after:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/blog/$
RewriteCond %{QUERY_STRING} ^p=998$
RewriteRule . /some/where/over-there? [L,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Hope this will help other people running WP and having the same problem!