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

I need to convert

RewriteEngine on
RewriteBase /generate
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)/ index.php?file=$2

To nginx conf

Can anyone help me with this? Important: The htaccess was in a folder called generate Give me a suitable code that will replace the htaccess in that folder Please show me exact code , looks complicated for me:)

share|improve this question
Put at least some effort into trying, or go hire a consultant. – 3molo Aug 12 '12 at 14:08
I converted the rest of the .htaccess . I am having problem with only this part – Werulz Aug 12 '12 at 14:39
up vote 2 down vote accepted

At the first time, you can try something like this:

    location /generate {
        if (!-e $request_filename) {
            rewrite ^/generate/(.*)/(.*)/ /generate/index.php?file=$2;

but it is not recommended.

Using try_files instead:

    location /generate {
        try_files $uri $uri/ @fallback;

    location @fallback {
        rewrite ^/generate/(.*)/(.*)/ /generate/index.php?file=$2 last;
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.