Redirect a subdomain to a specific url using DNS
33,393
Solution 1
You can not do this with DNS. DNS is used to map domain names to IP address(es). It can not resolve a domain to a specific URI.
Solution 2
If you use an Apache server you can achieve this using .htaccess file. You can try adding following lines to the file and see whether it works.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(?:www\.)?subdomain.domain1\.com$
RewriteRule ^(.*)$ http://www.domain2.net/subfolder$1
(or)
RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain\.domain1\.com$
RewriteRule ^(.*)$ www.domain2.net/subfolder$1
Author by
cmplieger
Updated on July 18, 2022Comments
-
cmplieger almost 2 years
I've redirected my domain http://domain1.com to http://domain2.com using a 301 redirect.
Now i would like to redirect subdomain.domain1.com to domain2.com/folder when the user arrives on that url.
Can I do this in dns? Or in some other way?
Thank you for your help!