example.com is hosted on VPS Host1 and I want to redirect blog.example.com to the shared host Host2. Since the sharing host doesn't provide a dedicated IP address so I could not set A record for the subdomain and redirect it to my IP address on Host2.

What are the possible ways of doing this?

  • Personally I'd choose another host as it says a lot about the type of web host your dealing with, since the majority of good hosts will provide you a static IP address. But, if you want to stay with them then you need to purchase a decent Dynamic DNS service, i.e dyn.com/remote-access but there are free ones but they are not as reliable since they have no service agreement. Jul 30 '17 at 13:27
  • @SimonHayter Can I just redirect it to my shared hosting's static IP? Does it work if that IP is being shared with other clients?
    – R. Toward
    Jul 30 '17 at 15:10
  • Yes, you can share a static IP address with thousands of other users. As long as the does not change then you don't need Dynamic DNS, you should be aware if you do used a shared IP then if you have SSL it will be SNI only which isn't compatible with older gen phones and browsers. Jul 30 '17 at 19:13
  • A dedicated IP address isn't required for redirects. Where did you hear that it was? Jul 31 '17 at 9:19

example.com is hosted on VPS Host1 and I want to redirect blog.example.com to the shared host Host2. .... What are the possible ways of doing this?

Let's assume the files that make up the site blog.example.com are stored on Host 1.

You can do any of these to make a redirect happen:

Either adjust server configuration to redirect URLs. The mod_rewrite module is handy for this if your Host1 allows you to use .htaccess files. See: http://httpd.apache.org/docs/current/mod/mod_rewrite.html

You can try javascript. You can insert the following code:


Here's more info on that: https://www.w3schools.com/jsref/met_loc_replace.asp

You can also use old-fashioned redirect by inserting the following line between "" and "" of your html:

<meta http-equiv="REFRESH" content="1;URL=http://newurl.example.com">

But the best way to do a redirect is by server-side ASP or PHP or equivalent coding such that the first two lines that must be sent to the client browser before any HTML is the following:

HTTP/1.1 301 Redirect
Location: http://newurl.example.com

Only thing that may vary is the word "Redirect".

In all cases, http://newurl.example.com is the URL to your home page on the target server.

There is no need to make special DNS changes (like A records) if your browser doesn't report an error generated by the browser (for example: Unable to connect to remote server).

Do realize that multiple domains and multiple sub-domains can be assigned the same IP address, and for that reason, I wouldn't recommend referencing anything on your pages to the IP address. This means don't make links that look something like this: http://xxx.xxx.xxx.xxx/somefolder/whatever.html (where xxx.xxx.xxx.xxx is your IP address).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.