Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blank or www catches url with subdomain #77

Open
bodgerbarnett opened this issue Dec 12, 2017 · 1 comment
Open

Blank or www catches url with subdomain #77

bodgerbarnett opened this issue Dec 12, 2017 · 1 comment

Comments

@bodgerbarnett
Copy link

If I have the following hosts.py:-

host_patterns = patterns(
    '',

    host(
        r'|www',
        'config.urls.cc',
        name='main'
    ),

host(
        r'manage',
        'config.urls.manage',
        name='manage'
    ),

    host(
        r'(?P<subdomain>\w+)',
        settings.ROOT_URLCONF,
        name='other'
    ),
)

and I go to example.com or www.example.com, I'd expect it to match the 1st host, which it does.

But if I go to manage.example.com, I'd expect it to match the 2nd in the list - or if I go to somethingelse.example.com, I'd expect it to match the last host. However, both of these urls are matched by the 1st host (the cc one).

Any ideas?

@jfajardo
Copy link

jfajardo commented May 5, 2018

I fix it with

from django.conf import settings
from django_hosts import patterns, host

host_patterns = patterns('',
    host(r'(www.example.com|example.com)', settings.ROOT_URLCONF, name='www'),
    host(r'(?P<domain>\w+)', 'apps.pages.urls', name='pages'),
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants