<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
<div><span class="Apple-style-span" style="background-color: rgb(255, 255, 255); "><font class="Apple-style-span" face="Tahoma" size="2"><div>Hi!</div><div>Im trying to move from Apache to nginx (v1.1.6), but you know, rewrite newbie here... In my site when a user types http://site.com he's redirected to http://site.com/en/, and all the other URLs are internally handled by an index.php. This is my actual Apache htaccess:</div><div><br></div><div> RewriteEngine On</div><div><br></div><div> RewriteCond %{HTTP:Accept-Language} ^en [NC]</div><div> RewriteRule ^$ /en/ [L,R=301]</div><div><br></div><div> RewriteCond %{HTTP:Accept-Language} ^es [NC]</div><div> RewriteRule ^$ /es/ [L,R=301]</div><div><br></div><div> RewriteCond %{REQUEST_FILENAME} !-f</div><div> RewriteCond %{REQUEST_FILENAME} !-d</div><div> RewriteRule (.*) index.php?ctr=$1 [QSA,L]</div><div><br></div><div>And this my translation to nginx:</div><div><br></div><div> location / {</div><div> if (-f $request_filename) { </div><div> expires 30d; </div><div> break; </div><div> }</div><div><br></div><div> if ($http_accept_language ~* "^es") {</div><div> rewrite ^/$ /es/ permanent;</div><div> break;</div><div> }</div><div><br></div><div> if ($http_accept_language ~* "^en") {</div><div> rewrite ^/$ /en/ permanent;</div><div> break;</div><div> }</div><div><br></div><div> if (!-e $request_filename) { </div><div> rewrite (.*) /index.php?ctr=$1 last; </div><div> } </div><div> }</div><div> location ~ \.php$ {</div><div> fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;</div><div> ...</div><div><br></div><div>With this, when I type http://site.com I'm being redirected to http://site.com/en/, great, but I get a 404 error, and in the error.log I have this line:</div><div><br></div><div> "/bla/bla/html/en/index.php" is not found </div><div><br></div><div>So, why is not nginx looking for the URI /index.php?ctr=/en/?</div></font></span></div> </div></body>
</html>