Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 have this htaccess:

<IfModule mod_rewrite.c>

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*) index.php?%{QUERY_STRING} [L]


to convert to nginx rules.

The problem is the last line.

Here is my current one :

  set $condition "";

  if (!-f $request_filename) {
    set $condition F;
  if (!-d $request_filename) {
    set $condition "${condition}D";
  if ($condition = FD) {
    rewrite ^(.*) $host/index.php?$query_string last;

How can I make this work ?

Thank you.

share|improve this question

Just erased $host and kept / and it's ok.

share|improve this answer

try this:

location / {
    try_files $uri $uri/ /index.php?$args;
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.