Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4052738
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:21:27+00:00 2026-05-20T14:21:27+00:00

I have a subdomain m.example.com that I want to point to the same location

  • 0

I have a subdomain m.example.com that I want to point to the same location as example.com/mobile running on an apache2/django1.3 installation.

example.com is the landing page, and I have the urls.py configured such that urls that match /^mobile$/ will be served the mobile version of the page. I looked into <VirtualHost>, but I think it requires a physical location for me to point m.example.com at and with the django urls there is no physical location except for the root of the project directory.

I am unsure if the configuration change is made on the apache side or the django side.

I’ve also looked into the mod_rewrite module for Apache, but I would prefer if I didnt have to redirect m.example.com to example.com/mobile

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T14:21:28+00:00Added an answer on May 20, 2026 at 2:21 pm

    I will avoid apache redirections, just using Middlewares.

    It’s common to use a middleware to get a context variable that gives the current domain that the user is using.

    From: http://djangosnippets.org/snippets/1119/

    class SubdomainMiddleware:
        """ Make the subdomain publicly available to classes """
    
        def process_request(self, request):
            domain_parts = request.get_host().split('.')
            if (len(domain_parts) > 2):
                subdomain = domain_parts[0]
                if (subdomain.lower() == 'www'):
                    subdomain = None
                domain = '.'.join(domain_parts[1:])
            else:
                subdomain = None
                domain = request.get_host()
    
            request.subdomain = subdomain
            request.domain = domain
    

    on your view, can use the subdomain and domain value to properly switch content and logic.

    def homepage(request):
        if request.subdomain == 'm':
             return movil_homepage(request)
        else:
             return default_homepage(request)
    

    You can even get decorators, and map all the views on your website.

    Even more common, it’s just to build a second project, that use the same database. It’s up to you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a sub domain that I want to redirect to a different location
If I have a site, example.com, and a page on that site references a
Say I have the following file: http://www.example.com/images/folder/image.jpg I want to serve it on http://s1.example.com/folder/image.jpg
I want to make a multi-lingual website that defaults to English like example.com with
I am building a site in asp.net and have multiple subdomains. For example, one.cookies.com
How do I create subdomain like http://user.mywebsite.example ? Do I have to access .htaccess
I have 2 hosts and I would like to point a subdomain on host
I have a website that i am hosting from home. I want to add
I have a Django application being served of (say) example.com . It contains a
We have a domain name with various TLDs. Let's use example.com as our main

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.