Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

254
Views
nginx if specific subdomain endpoint

I'd like to put robots.txt for the subdomain dev. to point to a specific robots.txt static file.

What routing rule do I need?

This is what i'm thinking:

if ($host = "dev.example.com") {
    location ^~ /robots.txt {
       allow all;
       root  /static/disallow/robots.txt;
    }
}

Based on Nginx subdomain configuration I believe I may need to just make separate server blocks and use include's. If not a simple routing rule, is the includes method how this is typically done?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

If you are wanting a specific robots.txt for each subdomain, you can do so with separate server blocks like this, which you allude (and link) to in your question:

server {
    server_name subdomainA.domain.com;
    include /common/config/path;
    location = /robots.txt {
        root /subdomainA/path;
    }
}
server {
    server_name subdomainB.domain.com;
    include /common/config/path;
    location = /robots.txt {
        root /subdomainB/path;
    }
}

Regarding your other approach, have you read If is Evil?

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!