How to remove index.php in Nginx

My server runs Nginx and when I’m searching how to remove index.php it always only help for apache.(Like This one and This one)

Today I was looking up in config.sample.php and saw this section:

/**
 * For server setups, that don't have `mod_env` enabled or restricted (e.g. suEXEC)
 * this parameter has to be set to true and will assume mod_rewrite.
 *
 * Please check, if `mod_rewrite` is active and functional before setting this
 * parameter and you updated your .htaccess with `occ maintenance:update:htaccess`.
 * Otherwise your nextcloud installation might not be reachable anymore.
 * For example, try accessing resources by leaving out `index.php` in the URL.
 */
'htaccess.IgnoreFrontController' => false,

I don’t know why but I added this line to my config.php and it works! (Nextcloud 20.0.3.2)

Here is how you may to do

  • First check if your nginx.conf or other configure file for your site is working.
    Simply just try to remove index.php from your url and see if there is any error.
  • If OK, add these lines to your config.php
'overwrite.cli.url' => 'https://Your_Domain/',
'htaccess.RewriteBase' => '/',
'htaccess.IgnoreFrontController' => true,

Change first two lines’ value if you need.
This should work (at least for me). If it doesn’t work please try to update your nc or try to do something described in apache ways.


I was posting this in [How to] section but then I found I don’t have permission LOL.
So I post it here because I didn’t find other place to post this.
BTW I am not a English-speaking so mistakes may be found in this post.


1 Like