Pergunta

It looks like this is a common issue since there are so many related questions here but I still have not found the solution after hours of searching...

I need to do many redirects via .htaccess for an old WordPress site. It uses URL's like this:

http://oldwpsite.com/?p=11
http://oldwpsite.com/?p=12

I need to redirect them something like this:

redirect 301 /?p=11 http://newwpsite.com/renting-a-scooter/  <--Does not work
redirect 301 /?p=12 http://newwpsite.com/scooter-tips/       <--Does not work

I have confirmed redirect does work with:

redirect 301 /xx.html http://newwpsite.com/  <--- Works

I tried many variations of RewriteEngine On, RewriteCond and RewriteRule but failed every time.

How can I do a redirect with question mark like the above?

Foi útil?

Solução

This should redirect the two pages to where you want them to go:

RewriteEngine on

RewriteCond %{THE_REQUEST} ^(GET|POST)\ /\?p=11\ HTTP
RewriteRule ^ http://newwpsite.com/renting-a-scooter? [R=301,L]

RewriteCond %{THE_REQUEST} ^(GET|POST)\ /\?p=12\ HTTP
RewriteRule ^ http://newwpsite.com/scooter-tips? [R=301,L]
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top