Mobile app version of vmapp.org
Login or Join
Correia994

: Redirect subdomain to another sharing host without dedicated IP 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

@Correia994

Posted in: #Dns #SharedHosting #WebHosting

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?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Correia994

1 Comments

Sorted by latest first Latest Oldest Best

 

@Angela700

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: httpd.apache.org/docs/current/mod/mod_rewrite.html
You can try javascript. You can insert the following code:

<script>
location.replace("http://newurl.example.com/");
</script>


Here's more info on that: 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: newurl.example.com

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

In all cases, 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: xxx.xxx.xxx.xxx/somefolder/whatever.html (where xxx.xxx.xxx.xxx is your IP address).

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme