Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Consider the following Nginx configuration file (Nginx version 1.2.6 on 64-bit Linux):

location / {
    root html/;
location /image/ {
    root html/;

Using this configuration, the following requests work as expected:


is picked up from the directory html/

/secure/profile.html is picked up from the directory html/

/image/logo.jpeg is picked up from the directory html/

However, the following requests result in errors (understandably):



What should be the correct Nginx configuration to ignore URL parts such as ;affiliate=msn and ~partner=msnbc?

share|improve this question
up vote 0 down vote accepted

Something like this

    location / {
        try_files $uri $uri/index.html =404;
    location ~ "(.*)[;~].*" {
        try_files $1 $1/index.html =404;
share|improve this answer
Although we had solved the problem before your answer, I really appreciate your taking out the time to answer the question. I am accepting your answer as it is indeed a valid solution to the problem we were facing. The only thing would be to escape the semi-colon as [\;\~]. Without escaping it our Nginx installation would find the configuration file invalid. – Jan 27 '13 at 12:28

Have changed the configuration as follows to get the desired behaviour.

location /image/ {
    rewrite ^(/image/.*)[\;\,\~].*$ $1 break;
    root    html/;

Please note that semi-colon has to be escaped (\;) since it is a statement delimiter in Nginx configuration files.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.