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

  • SEARCH
  • Home
  • 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 Python app at www.example.com. I want to create a subdomain that
I have a controller Partners that I want to server off of http://partners.example.com Is
Say I have a subdomain xxx.yyy.com running Apache. The files are stored in /home/someone/public_html/xxx
I have modified my etc/hosts file (under Windows 7), so that www.example.com and demo.example.com
If I have a site, example.com, and a page on that site references a
I want to redirect a praticular subdomain to the main domain http(s)://dl.example.com/par1/par2 to http(s)://www.example.com/par1/par2
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'm running a site on an apache server named www.example.com which has sub.example.com subdomain.
I have a sub domain that I want to redirect to a different location

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.