Apache mod_rewrite is for you, the "Rewrite" methods combined with regular expressions should feat your needs perfectly
create a ".htaccess" file in your public dir at hosting A for example
insert this lines :
<IfModule mod_rewrite.c> RewriteEngine On # redirect pageZ to http://pages.site5.com/pageZ # http://www.site1.com/pageZ redir to http://pages.site5.com/pageZ RewriteRule ^(pageZ)$ http://pages.site5.com/$1 # redirect pageY to http://pages.site5.com/pageY RewriteRule ^(pageY)$ http://pages.site5.com/$1 # calling any url starting with "page" and followed by any caracter RewriteCond % ^(page.)$ # then redirect the uri to the following RewriteRule ^(.*)$ http://pages.site5.com/$1 [L] </IfModule>
You can find a guide at : https://httpd.apache.org/docs/2.0/misc/rewriteguide.html