How do I rewrite a request by hostname unless it is a specified value?
        Posted  
        
            by 
                Tim
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Tim
        
        
        
        Published on 2012-10-06T23:43:16Z
        Indexed on 
            2012/10/07
            3:38 UTC
        
        
        Read the original article
        Hit count: 236
        
My app will have a regular domain - let's say example.com - which will have information about logging in, signing up, etc. It will also host numerous other domains dynamically. My app serves the webpage for these at http://example.com/site/foobar.com/
So, I need to redirect all requests where the hostname is not example.com to /site/[hostname]/
I'm writing this in Django and hosting with Apache.
How do I set up a rewrite rule to do this? The user must not know they are on any other site but foobar.com and if the user browses to foobar.com/something - the URL must be rewritten to /site/foobar.com/something
© Stack Overflow or respective owner