Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I own 2 domain names "domain1.com" and "domain2.com", I want to redirect subdomain.domain1.com to domain2.com/directory using DNS (preferably). Can anyone assist (I am an amateur at domain management)?

share|improve this question
Depends on your registrar, and may require premium DNS. Email them. – Simon Hayter Apr 12 '13 at 9:08
@byde: What's "premium DNS" in this sense? AFAIK DNS cannot handle subdirectories/paths. So this is not possible using DNS alone. – w3dk Apr 12 '13 at 9:57
It is possible, checkout dyn.com/support/webhops-and-redirections sorry my 1st comment was brief. – Simon Hayter Apr 12 '13 at 22:55

You can use a simple redirect pointing subdomain.domain1.com to domain2.com/directory.

In order to do this open your public_html folder. You will see a .htaccess file present under the public_html folder.

Add this code in the .htaccess file:

RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com
RewriteRule ^(.*)$ http://domain.com/subfolder/$1 [R=301]
share|improve this answer
I do not have access to domain1.com htaccess because I only own the domain for that, which is why I am searching for DNS configuration. +1 for the answer though. :) – anonymuz Apr 12 '13 at 7:45
@Vivin: so you have a DNS entry for domain1.com, a DNS entry for domain2.com, and a server handling requests for domain2.com? – Ulrich Schwarz Apr 12 '13 at 10:46
@Vivin: You can contact your domain registrar for domain1 and ask them to point or redirect your domain name to the desired web address and yes this can be done. :) You can do this yourself if you have been provided a domain management panel by your current registrar which provides the redirection feature. – Nilabh Apr 12 '13 at 17:14

Some premium dns providers provide extra features at dns level such as Dyn do.

Quote on Dyn's Webhop service

Redirecting a Subdomain to a Subdirectory


http://myhost.dyndns.org/ redirects to http://myserver.dyndns.org/~myhomepage/

In many instances, you may wish to redirect from a subdomain (e.g. subdom.domain.com) to a subdirectory of your main site (e.g. www.domain.com/subdir). While creating a WebHop redirect is a simple enough solution, a better solution is to use either virtual hosting or a 301 server-side redirection instead..

While the quote isn't a 100% match it should in theory and gives you an idea that 'somethings' can be done at dns level, however they do advise that this should ideally be done at hosting level, if you do consider this a viable solution ensure you question them beforehand as I do not have firsthand experience but have heard of others doing it a similar way.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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