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

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

2 Answers 2

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.