I have a client with a site at subdomain.example.com/folder.

I've cloned it locally in MAMP. Once I've made some changes, I need to host it at an alternative physical server (I intend to use a dedicated server I have access to with a technical domain name currently). However, the client would like to keep the existing URL as it has been used extensively in marketing.

I've done HTTP redirects and forwards and 301 redirects in the past, but I'm not sure how or even if I can do what the client wants. How can I achieve this, possibly using .htaccess and DNS entries?

Caveats: I can't have the site at a 3rd party domain and the client isn't able/allowed to register any additional domains.

  • So you just want to host the contents of the subdirectory on the new server while subdomain.theirdomain.com still points to the current server (without changing DNS entries)? – maff Jul 9 '12 at 12:10
  • "I can't have the site at a 3rd party domain and the client isn't able/allowed to register any additional domains" - So register it for them. But can't you simply redirect the traffic using javascript? I know this is possible since I have done it on my own domain I have hosted with the horrible service known as GoDaddy – Ramhound Jul 9 '12 at 17:54
  • 1
    I'm confused. If they want to keep the existing URL, why aren't you just putting the updated site back where it's already hosted? There's a bunch of talk about putting it on a new server and whatnot, but no explanation for why the new server even comes into play. (Beyond that, if I'm reading things correctly you can probably do this with a CNAME, I'm just not following why the problem exists at all.) – Su' Jul 11 '12 at 9:49

You can use a file called as .htaccess stealth redirection in order to redirect your website using the .htaccess.

The code for the same is:

RewriteCond %{HTTP_HOST} ^(www\.example\.com)?$
RewriteRule ^(.*)$ http://example.com/subfoldername/$1 [P,L]

In case, you wish to host the subdomain on a different server then, you will have to add an A record pointing the subdomain to the IP address of the new server.

I am a bit confused regarding the question and will really appreciate if you can point out the exact requirements.

I have answered the question as per my understanding. Feel free to correct me in any case.


Just update the DNS records for the whole site?

If it's for a folder only, you can add a redirect script based upon the URL?

You have a few comments which I think you need to answer before any one can help.

Your Answer

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