I have a site that was temporarily set up as 111.222.333.444/~mysite because the real URL was not ready. 111.222.333.444/~mysite/?page_id=123 was a valid page on that site. My site is live now. I no longer want or need to use 111.222.333.444/~mysite to access the site.
However Google has indexed a search for a term on page ?page_id=123 as 111.222.333.444/~mysite/?page_id=123. But ?page_id=123 no longer exists. It's now on a new page, and I want to redirect Google's link to www.example.com/newpage
The closest I have come to implemeting this redirect is:
RewriteCond %{HTTP_HOST} ^111\222\.333\.444$ [NC]
RewriteCond %{QUERY_STRING} ^\?page_id=123$ [NC]
RewriteRule ^~mysite/$ //www.example.com/newpage [R=301,NE,NC,L]
But this doesn't work, and gives me an internal server error.
I have also tried:
Redirect 301 /?page_id=195 /newpage
But that had no effect. Can anyone suggest how to do this? I don't have a problem redirecting single pages, but the temporary/alternate URL with the IP address is throwing me.