I have a single application which manages and delivers several sites. I does this by determining which domain to serve from the URL:
http://myapplication.com/site_1/ or http://myapplication.com/site_2/
Each site obviously has it's own pages, so might end up with a url like this:
http://myapplication.com/site_1/contact_us/
What I'd like to do is create some middleware which, when a url such as the two above (http://myapplication.com/somedomainhere) it will check the existence of that particular domain in a database (which I have already created) and, if it exists, continue to the index view. If the domain doesn't exist, I want to divert to a 404 page.
Is this something which is relatively simple to do with middleware and if so, does anyone have any examples of how I might go about accomplishing this?
I am aware of the Sites framework which comes with Django, but I will be using the above to create something slightly different.