1

I've a problem with nginx configuration (that i get working with apache). I've to do a rewrite so I've configured:

    location = / {
            root   /var/www/domain.tld/public_html;
            index  index.php;
    }

    location / {
            root   /var/www/domain.tld/public_html;
            index  index.php;

            if (!-f $request_filename) {
                    rewrite  ^(.*)$  /index.php last;
                    break;
            }

            if (!-d $request_filename) {
                    rewrite  ^(.*)$  /index.php last;
                    break;
            }
    }


    # serve static files directly
    location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|wmv)$ {
            access_log        off;
            expires           30d;
    }

The problem is that I've static files located in dirs like /css, /img, /js but I also have a php controller that serves the user uploaded files and has the structure: domain.tld/media/image/NAME/EXTENSION. This doesn't works because it tries to get a static file, but If I go with domain.tld/media/image/NAME/EXTENSION/ (note the final /) it works.

How I can solve this?

Thank you in advance!

1 Answer 1

3

You didn't read the documentation, did you? ;) It is listed in common pitfalls from users coming from Apache. Use the try_files directive, as described here: http://wiki.nginx.org/Pitfalls#Check_IF_File_Exists

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.