Most apache rewrite conditions should not be turned into if blocks. Those conditions matching HTTP_HOST should be turned into server blocks, those matching the uri or request filename should be replaced with location blocks, and those testing existence of files should be replaced with try_files. Please don't use if blocks where they're not necessary. Assuming that all dynamic requests are supposed to go through php, I think the correct translation of those rules is: