0

Something I'm trying to figure out now is to setup custom domain hosting so users can host a profile page on any domain of their choosing. I was able to get it to work now but it requires a lot of custom work.

My current setup is to have the user change their DNS settings to redirect to my domain. Then on my domain I add another virtual host to deal with this new domain and then update my Django middleware to look at the PATH_INFO within the request in order to choose the page to serve.

Is there a way this can be changed to automate this process so this can be done entirely automatically without modifying Apache or the middleware? I was thinking of using mod_rewrite to pass this info along to a specific page in Django and then doing a lookup in a table to see the page this page to display for this domain.

1 Answer 1

3

You should be able to set up your webserver such that it will accept any domain pointed at it. Once you've done that, the user needs only to create an A record pointing their domain or a subdomain to the IP address of your site, and then their domain will bring up your site.

Then, you would just need to setup some domain checks in your views (request.get_host()). For instance, your index view should branch on the host, loading your homepage for your domain and the user's profile for any other domain. You can have the user add their domain to their profile and then use that to lookup the right profile. You might need to add some middleware to protect other views from being accessed by anything but your domain, but that's basically the process.

Sign up to request clarification or add additional context in comments.

2 Comments

Yea - this makes sense but should I be doing anything with mod_rewrite or should I rely on the middleware to do the work entirely?
The idea is to prevent domains other than yours rendering views on your site (other than the actual profile view you're allowing). However you want to achieve that and what works best for your setup is up to you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.