Jump to content

How to make a custom subdomain point to a custom domain


Recommended Posts

Hi, 

I have been working with domains and servers for a very long time but I simply cannot figure out a solution to my problem.

I have a system that dynamically creates subdomains and access user-created pages based on the username. So a user may create "xyz.mydomain.com" and it will go to the home page of their site. They can also create other pages like "xyz.mydomain.com/bio" and it will go to the page they created and named "bio". 

My issue lies when I want to give the user a custom domain to use for their site. If they register xyz.com, I want to set up the server so that visitors can go to xyz.com/bio and it will show the content for "xyz.mydomain.com/bio" but without redirecting to mydomain.com. 

A frame redirect is not a solution because when a user clicks a link within the website, the URL needs to reflect the page that they clicked, so from the home page, if they click the 'bio' link, the URL needs to show "xyz.com/bio"
Link to comment
Share on other sites

not sure what virtualhosts is,

So it's not that then.

 

You have code that checks the subdomain, presumably using HTTP_HOST. Modify the code so that it does more than just check the subdomain, such as "if the host is X.mydomain.com then the user is X, else if the host is not *.mydomain.com then determine the user by looking up the entire hostname in the database".

 

If you want more help then you'll have to explain the system in much more detail. Like where the subdomain checking takes place, how you're looking up the user, and where you're storing the custom domain names. And the code to go along with it.

 

Oh, and this entire system will only work if you have dedicated hosting.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.