Attempting to run a subdomain for main site only on Centos 8, with main domain remaining on another server

Issues related to configuring your network
Post Reply
Posts: 1
Joined: 2020/09/24 16:44:49

Attempting to run a subdomain for main site only on Centos 8, with main domain remaining on another server

Post by anne282 » 2020/09/24 17:11:08

Good morning,

This is a temporary situation, as I am in the process of migrating all of my servers over to the Centos 8 Linux server that I have started to build. Since this will take some time, I am trying to do the following.

I have a website with multiple subdomains. One of the subdomains hosts a photo gallery, which I was forced to remove from its original server by the hosting provider. As a result, I purchased a Centos 8 VPS server, and have uploaded the entire photo gallery to it. I also added LAMP to this server.

What I would like to do is make ONLY this one subdomain, as well as all internal subdomain links on each page of the subdomain, be hosted on this server. In addition to this, the nameservers for the domain are presently hosted with Cloudflare for security, although I am not certain that this is relevant to the situation I have encountered.

Not only this, but I would like the URL field to show ONLY the subdomain name, without any subfolders added, as this is how the htaccess files on the site were written, and changing every single one of them for a temporary amount of time would be extremely time-consuming, and once full migration happens, they would have to be changed back.

Thus far, what I had tried was to use Apache to redirect the subdomain, but this was not successful, as the subdomain became a folder name, and thus when the links on the pages were clicked, they all went to page not found. This was because the htaccess files in each of the subdomain folders redirects to the subdomain as a tld, i.e. But when the main htaccess was edited, with the following code:

Options +FollowSymlinks
RewriteEngine on

RewriteRule ^$ /Parties-Kids [L]

It instead shows in the url field: Thus, the main subdomain page does work, but when a link is clicked, it goes to a page that states "file not found".

So, what I did next was to remove the htaccess file from the main folder, install webmin, and use BIND DNS. I created a master zone with the subdomain as a tld. Then I created the A records, with the initial a record field blank, and with a www field, all set to the IP address. I then created two nameservers, using the main domain as the tld.

Initially, I had created the nameservers using the Cloudflare nameservers, but as that caused an error, I changed them to the nameservers for the main domain itself (

I am waiting for this change to propagate, as I was able to restart the bind server, and I would like to know if I did this correctly for the purpose described above.

As of right now, when I go to the main page of the Centos 8 server, with the subdomain (when it was redirected from Cloudflare), it shows a test index.html file that I had put in, rather than the master zone that I had created to go along with that subdomain.

Is it possible that this would work, or is there a different way that it should be done? I used the instructions I found at serverpronto's website, which gives instructions for adding a new hosted domain to a server using Webmin.

At this time, the website is not being redirected, as I removed the new IP address from cloudflare's redirection area, since it wasn't working, so I cannot really provide a meaningful example of what is happening right now. Where it is located on the old server (which is on a managed hosting plan with cPanel), it still works, but I do not want to leave it broken until I find a solution.

However, whenever I do redirect it, the URL address bar shows what is above, and all links on the page do not work.

Perhaps there is a different solution that I would need to use for this particular situation (making a subdomain on a different server than the main domain is on). Any help would be greatly appreciated. Thank you.

Posts: 327
Joined: 2019/10/09 12:31:40

Re: Attempting to run a subdomain for main site only on Centos 8, with main domain remaining on another server

Post by BShT » 2020/09/24 19:13:22

create a vhost for that subdomain and set DNS

no rewrite is needed

User avatar
Posts: 347
Joined: 2013/12/18 15:04:03
Location: xfs file system

Re: Attempting to run a subdomain for main site only on Centos 8, with main domain remaining on another server

Post by KernelOops » 2020/09/24 19:38:33

So you have a subdomain that is hosted on a CentOS 8 server, if setup and a virtual host on that server, it should work without modifications, you only need to set the IP address of the subdomain to point to the new server.

At least thats what I understood from your description.
I love my computer - all my friends live there.

Post Reply

Return to “CentOS 8 - Networking Support”