In my case, $file_rul is something like `http://localhost:8080/sub/page`.
Replacing this:

    if($file_url == "/") {
        $file_url = 'index';
    }

with this: 

	$file_url = parse_url($file_url, PHP_URL_PATH);
	if (substr($file_url, -1) == '/') {
		$file_url .= 'index';
	}

fixed the problem.