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

119
Views
Excluding URLs from Django redirects

Im redirecting all my files on the root of my site to the English subdirectory

url(r'^(?P<zero>([a-z-]*)).(htm|php|html)$', redirect, {'to': '/en/{0}.html', 'permanent': True}),

I want to exclude a specific page. If I were using apache I could easily do this with an alias or a mod rewrite before it hits the Django application. However Im using Nginx and the redirect gets process regardless of the alias. Is there a rule I can use above so a specific page on my root won't get redirected?

the following is an example of my config with using regx, tried it with suggested one above as well (location ^~ /file.html { )

 listen 8007;
    server_name  devel.somedomain.com;
    access_log  /var/log/nginx/somedomain-dev.log;
    error_log /var/log/nginx/error.log;
    real_ip_header X-Forwarded-For;
    set_real_ip_from 0.0.0.0/0;
    #real_ip_recursive on;

    location ~ /help.cgi$  {

        proxy_pass http://localhost:8006;
    }

    location ^~* /file\.html$ {
        alias /home/admin/somedomain/file.html;
    }
    location / {
       proxy_pass http://127.0.0.1:8006;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

It's even easier in nginx.

location ^~ /file_name {
     alias /path/to/file_name;
}

Put that before the proxy_pass.

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!