I have a subdoman called, let's say:
cloud.mygizmo.com
But when someone navigates to this URL I want them to actually go to:
11.22.33.44/cloud
Which is on a completely different host from mygizmo.com
and can't be moved.
In my .htaccess
I have this:
RewriteEngine on
# Use PHP5.4 as default
AddHandler application/x-httpd-php54 .php
RewriteCond %{HTTP_HOST} ^cloud\.mygizmo\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.cloud\.mygizmo\.com$
RewriteRule ^/?$ "http\:\/\/11\.22\.33\44\/cloud" [L]
Which does do the redirect, but it still changes the address bar in the user's browser.
How do I make it so that if a user navigates to cloud.mygizmo.com
they actually go to 11.22.33.44/cloud
but the address bar still says cloud.mygizmo.com
?
You can't. Redirection doesn't work like that.
You could proxy the data instead (which would be inefficient and increase your bandwidth costs).
If you have mod_proxy installed, you can use the P
flag to reverse proxy on behalf of the browser:
RewriteEngine on
# Use PHP5.4 as default
AddHandler application/x-httpd-php54 .php
RewriteCond %{HTTP_HOST} ^cloud\.mygizmo\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.cloud\.mygizmo\.com$
RewriteRule ^/?$ "http\:\/\/11\.22\.33\44\/cloud" [L,P]
You can also reverse proxy using ProxyPass
or ProxyPassMatch
but those will only work in the vhost/server config.
In the cloud.mygizmo.com
/www.cloud.mygizmo.com
vhost you can say:
ProxyPass / http://11.22.33.44/cloud
And then any request for the cloud.mygizmo.com
gets proxied to the http://11.22.33.44/cloud
host.
Note that ProxyPass
works like Redirect
, it links together the path nodes /
and /cloud
. So if someone were to go to:
http://cloud.mygizmo.com/foo/bar
They'd get reverse proxied to:
http://11.22.33.44/cloud/foo/bar
If that's not what you want, then use ProxyPassMatch
:
ProxyPassMatch ^/$ http://11.22.33.44/cloud
Alternatively, if you want the rewrite rule to behave in the same way, you need to capture the request URI and pass it to the target with a backreference:
RewriteRule ^/?(.*)$ http://11.22.33.44/cloud/$1 [L,P]
probably not the ideal solution, but you could build a page that's pretty much a giant iframe and load the content inside the iframe...
Edit: See if Blue Host allows Parked Domains in your control panel (aka Masked Forward). I think this is what you want.