has anyone ever used wildcard subdomains in their application? I need to come up with a way to ‘localise’ my application. When i say localise i mean anyone who goes to ny.foo.com/items/new/ will be sent to a view which looks through a database and search for new items in ny. Obviously we could replace NY with any state.
Any tips would be great
Thanks!
I would do it using a middleware, eg.:
And then in any of your views, you can just check
request.state_codeand fetch new items only for that state.Edit: For development, the best method is to setup a local DNS server. Eg. dnsmasq is very easy to configure:
address=/.dev/127.0.0.1 # in dnsmasq.confThis makes
*.devpoint to localhost. You’ll also have to configure your system to use the local DNS server (on UNIX systems you do this by placingnameserver 127.0.0.1into/etc/resolve.conf).Alternatively, you can list all the domain names in your /etc/hosts if it is a finite set: