title: converting apache htaccess to nginx
body: <p>I am trying to convert apache htaccess rule to nginx config but it is not working. Following are the details of rules and nginx config:</p>
  
  <p><strong>.htaccess Rule</strong></p>
  
  <p><code>RewriteBase /</code></p>
  
  <p><code>RewriteCond %{REQUEST_FILENAME} !-f</code></p>
  
  <p><code>RewriteCond %{REQUEST_FILENAME} !-d</code></p>
  
  <p><code>RewriteRule ^(.*)$ index.php/$1 [L]</code></p>
  
  <p><strong>Nginx Config For Above</strong></p>
  
  <pre><code>server {
  
      listen      ip_address:80;
  
      server_name  www.example.com;
  
      access_log /var/log/nginx/example.com-access.log;
  
      error_log /var/log/nginx/example.com-error.log;
  
      root   /var/www/html/example.com/;
  
      index  index.php;
  
  location / {
  
                  if (!-e $request_filename){
  
                  rewrite ^(.*)$ /index.php/$1 break;
  
  }
  
  }
  </code></pre>
  
  <p>when i access website it opens home page and when i click other menus it gives 404 not found.</p>
  
  <p>Following is the error log:</p>
  
  <p><code>2015/03/18 05:31:56 [error] 3550#0: *7 open() "/var/www/html/example/index.php//contents.html" failed (20: Not a directory), client:</code></p>
  
  <p><code>1.2.3.4, server: www.example.com, request: "GET /contents.html HTTP/1.1", host: "www.example.com", referrer: "http://example.com/"</code></p>
  
  <p>any ideas???</p>
  
  <p>Shoaib..</p>