How to auto add .php after filename with this kind of url: download?a=x&b=y&.... and auto add index.php if we type www.domain.com/ or domain.com/ I tried but it does not work if (-f $request_filename/index.php) { rewrite (.*) $1/index.php break; } if (-f $request_filename.php) { rewrite (.*) $1.php break; }