title: Apache mod_rewrite to Nginx rewrite rules
body: <p>My site is running on Nginx and I am trying to add a software in the sub-directory of the site that uses Apache's mod_rewrite rules. E.g. www.mydomain.com/mySubfolder</p>
  
  <p>Here is the Apache .htaccess</p>
  
  <pre><code>#Options -Indexes
  &lt;ifModule mod_rewrite.c&gt;
      RewriteEngine On
      RewriteCond %{REQUEST_URI} ^/system.*
      RewriteRule ^(.*)$ index.php?/$1 [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.+)$ index.php?/$1 [L]
  &lt;/ifModule&gt;
  </code></pre>
  
  <p>So far I managed to get the main page to work but when requesting the login page, it is causing a URL redirect loop. E.g. www.myDomain.com/login 
  With this:</p>
  
  <pre><code>location /mySubfolder {
  if (!-e $request_filename) {
  rewrite ^(.*)$ /mySubfolder/index.php?q=$1 last;
  break;
  }
  }
  </code></pre>
  
  <p>I have been reading and trying to learn how to convert Apache to Nginx and even used the .htaccess to Nginx converter I found at <a href="http://winginx.com/htaccess" rel="nofollow">http://winginx.com/htaccess</a> but the tool doesn't seem to recognize the %{REQUEST_URI} ^/system.* part. Upon my research and study, I came up with:</p>
  
  <pre><code>location /mySubfolder {
  if ($request_uri ~ "^/(system.*)$") {
  rewrite ^/(.*)$ index.php?/$1 last;
  }
  if (!-e $request_filename) {
  rewrite ^(.+)$ /mySubfolder/index.php?q=$1 last;
  break;
  }
  }
  </code></pre>
  
  <p>I am a complete noob at this and was even wondering if I am even close to accomplish this conversion to work. Please help.</p>
  
  <p>Thank you. </p>