By mvokal
Hi, I have two droplets that are each currently accessed through their own domains (let’s called them domainA and domainB). However, I would like to merge the domains so that the droplet accessed via domainB is a now accessed as a subdomain of domainA.
I created an A record for a subdomain for domainA, and when I navigate to subdomain.domainA.com it successfully takes me to the site hosted on domainB’s droplet. However, the url in the browser changes to domainB.com instead of staying subdomain.domainA.com. What should I do to make sure the url displays correctly?
Additionally, I will likely keep domainB around for awhile in case old users try to return to it, but I would like it to redirect to subdomain.domainA.com. However I still want to keep the subdomain on a different droplet so I don’t have to change all the db references and such in my code.
Thanks!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Your web server configuration is what you want to look into to stop the URL being rewritten. Or it’s possibly a setting of the application you’re hosting. It is unrelated to DNS.
Hi, there are several places you might have to set it:
If you have wordpress and change domain I believe you have to do some updates at least in inline links between posts, unless they are relative (which they often are not). There are often plugins to do such tasks or you can of course do it in sql queries with updates (with replace). But if you do that, please remember to take backups first :-)
You can of course make a copy of your website and copy your db and fix it in a copy… Then you set the subdomain of domain A to point to the new copy of your webpage. Then when everything works fine with the subdomain webpage, you just make a 301 redirect (permanently moved) from the old domain to the new. Google and others will respect your 301.
For anyone reading this in the future, I had to modify my default-ssl.conf file in the server that I want the subdomain to point to as follows:
<VirtualHost *:80>
ServerName subdomain.domainA.com
Redirect permanent / https://subdomain.domainA.com/
</VirtualHost>
<VirtualHost *:443>
ServerAdmin xxx@yyy.com
ServerName subdomain.domainA.com:443
DocumentRoot /path
#SSL certificates for subdomain.domainA.com
</VirtualHost>
<VirtualHost *:443>
ServerAdmin xxx@yyy.com
ServerName domainB.com:443
Redirect permanent / https://subdomain.domainA.com/
DocumentRoot /path
#SSL certificates for domainB.com
</VirtualHost>
Since I used permanent redirects it was important to make sure that I had the SSL certificates for both the old domain and the new subdomain as many users’ browsers were redirecting them to https://domainB.com.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.