Categories on Subdomains.

NodeBB Development
  • #1

    Coming up with thoughts left, right, center and upside down, but running into roadblocks.

    If I wanted to have a category attached to a subdomain, what would be the best way to achieve this? I went about this quite heavy handedly, so, I've got a wildcard CNAME in cloudflare that points to my site. I've then set up another nginx config that looks for specific subdomains (I'll use in this case(because it's one I actually set up)), which I want to point at a specific category only.

    I thought about just redirecting it, but would rather the domain remain unchanged, so would just show the dnb category. However this adds additional issues when it comes to moving between pages. As the URL is still dnb.35hz, but the actual site is, so everything 404s.

    Is a redirect the realistic only way to do this/am I being over optimistic with my plans? 😆

  • Plugin & Theme Dev

    I like it.

  • #3

    @Tanner I like the idea of it, not sure how likely it is to work in the real world though. 😆

  • GNU/Linux

    A custom theme that removes the links back to other parts of the site might work...

  • #5

    @julian 😢 I was hoping for something that didn't require work. 😛 The bigger issue is the routes break, think that's more a core thing. The link in my first post works if you'd like to see what I mean. 🙂

    I don't mind using redirects, it's possibly easier that way thinking about it.

  • #6

    Honestly, this looks more like a job for rewrites.

  • #7

    @a_5mith - I get a category with broken CSS when using a browser without your site being cached. 😞

  • #8

    Nice. This is pretty cool.

  • #9

    @Ted yeah, any links to things like nodejs.min and the style sheets don't work, because it looks for them on the DNB subdomain. Which technically isn't correct. 😆

  • #10

    After some playing about, i've settled on a redirect. If anyone wants to do something similar, create a new file in sites-available called subdomains, then do the usual sudo ln -s /etc/nginx/sites-available/subdomains /etc/nginx/sites-enabled

    Inside the subdomains file, create a server block like thus:

    # Mixes
    server {
        listen 80;
        rewrite     ^ $scheme://$request_uri? permanent;

    If you want the subdomain to ignore the request parameter, then remove $request_uri? portion of the rewrite. This basically means that if someone typed it would ignore /parameter and still go to the relevant tag page without causing a 404. This may be more beneficial. So I'd recommend leaving that portion out. However this would be useful if you wanted a fast way to navigate to a user profile via something like Because you could add the request_uri after /user in the rewrite.

    Just add more server blocks as required for each rewrite. You can stack server_names so that multiple subdomains go to the same link, just add another server_name underneath the existing one.


Suggested Topics

| | | |