Nginx – How to rewrite query string rules htaccess in nginx

.htaccessnginxrewrite

I have this htaccess:

<IfModule mod_rewrite.c>

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

</IfModule>

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.

Best Answer

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

Related Topic