# Removing index.php from the Nextcloud URI

**URL:** <https://help.nextcloud.com/t/removing-index-php-from-the-nextcloud-uri/13055>\
**Category:** ℹ️ Support\
**Created:** [May 24, 2017, 11:54am UTC](https://help.nextcloud.com/t/removing-index-php-from-the-nextcloud-uri/13055 "2017-05-24T11:54:02Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aasemoon](https://help.nextcloud.com/user_avatar/help.nextcloud.com/aasemoon/32/4233_2.png) [@Aasemoon](https://help.nextcloud.com/u/Aasemoon)\
**Post date:** [May 24, 2017, 11:54am UTC](https://help.nextcloud.com/t/removing-index-php-from-the-nextcloud-uri/13055/1 "2017-05-24T11:54:02Z")

</div>

Hi there,

I’ve seen this topic of removing index.php from Nextcloud address discussed in a few older [and now closed] threads already, but I don’t seem to be able to find a solid and final solution anywhere. That is why I’m posting this question again, despite it being discussed before. Is there an actual solution for this?

The relevant information:

Nextcloud version _(12.0.0)_:  
Operating system and version _(CentOS 6)_:  
Apache or nginx version _(Apache 2.2.32)_:  
PHP version _(7.0.12)_:

I can also tel you that as far as I can see in my .htaccess, mod\_env and mod\_rewrite seem to be enabled. And I use a shared host at the moment [Bluehost]. And FastCGI is enabled.

I’d appreciate any solutions you can suggest.

Cheers!

---

<div class="post-metadata">

**Author:** ![clouduser](https://help.nextcloud.com/letter_avatar/clouduser/32/6_22734026db12803ebb3e059622ac3534.png) [@clouduser](https://help.nextcloud.com/u/clouduser)\
**Post date:** [May 24, 2017, 12:16pm UTC](https://help.nextcloud.com/t/removing-index-php-from-the-nextcloud-uri/13055/2 "2017-05-24T12:16:47Z")

</div>

This works on CentOS **7**!

Add this to your config.php

`'htaccess.RewriteBase' => '/'` (Path depends on your configuration - maybe `/nextcloud`)

Update htaccess with the occ command  
`sudo -u apache php occ maintenance:update:htaccess`

Make sure all modules are enabled with  
`cat /etc/httpd/conf.modules.d/* | grep mod_env`  
and  
`cat /etc/httpd/conf.modules.d/* | grep mod_rewrite`

The output line should not start with `#`

I also restarted my httpd  
`systemctl restart httpd`

---

<div class="post-metadata">

**Author:** ![Aasemoon](https://help.nextcloud.com/user_avatar/help.nextcloud.com/aasemoon/32/4233_2.png) [@Aasemoon](https://help.nextcloud.com/u/Aasemoon)\
**Post date:** [May 24, 2017, 1:08pm UTC](https://help.nextcloud.com/t/removing-index-php-from-the-nextcloud-uri/13055/3 "2017-05-24T13:08:24Z")

</div>

Thanks for your response,

I have added `'htaccess.RewriteBase' => '/'` to config.php, and I’m sure both modules are enabled.  
However using a shared host I do not have sudo rights. What should my .htaccess look like after this?

---

<div class="post-metadata">

**Author:** ![clouduser](https://help.nextcloud.com/letter_avatar/clouduser/32/6_22734026db12803ebb3e059622ac3534.png) [@clouduser](https://help.nextcloud.com/u/clouduser)\
**Post date:** [May 24, 2017, 2:39pm UTC](https://help.nextcloud.com/t/removing-index-php-from-the-nextcloud-uri/13055/4 "2017-05-24T14:39:33Z")

</div>

I compared my .htaccess with the current file from github…

This was added:

```
ErrorDocument 403 /core/templates/403.php
ErrorDocument 404 /core/templates/404.php
<IfModule mod_rewrite.c>
  Options -MultiViews
  RewriteRule ^core/js/oc.js$ index.php [PT,E=PATH_INFO:$1]
  RewriteRule ^core/preview.png$ index.php [PT,E=PATH_INFO:$1]
  RewriteCond %{REQUEST_FILENAME} !\.(css|js|svg|gif|png|html|ttf|woff|ico|jpg|jpeg)$
  RewriteCond %{REQUEST_FILENAME} !core/img/favicon.ico$
  RewriteCond %{REQUEST_FILENAME} !core/img/manifest.json$
  RewriteCond %{REQUEST_FILENAME} !/remote.php
  RewriteCond %{REQUEST_FILENAME} !/public.php
  RewriteCond %{REQUEST_FILENAME} !/cron.php
  RewriteCond %{REQUEST_FILENAME} !/core/ajax/update.php
  RewriteCond %{REQUEST_FILENAME} !/status.php
  RewriteCond %{REQUEST_FILENAME} !/ocs/v1.php
  RewriteCond %{REQUEST_FILENAME} !/ocs/v2.php
  RewriteCond %{REQUEST_FILENAME} !/robots.txt
  RewriteCond %{REQUEST_FILENAME} !/updater/
  RewriteCond %{REQUEST_FILENAME} !/ocs-provider/
  RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/.*
  RewriteRule . index.php [PT,E=PATH_INFO:$1]
  RewriteBase /
  <IfModule mod_env.c>
    SetEnv front_controller_active true
    <IfModule mod_dir.c>
      DirectorySlash off
    </IfModule>
  </IfModule>
</IfModule>

```

You can try it but without guarantee 😉

---

<div class="post-metadata">

**Author:** ![Aasemoon](https://help.nextcloud.com/user_avatar/help.nextcloud.com/aasemoon/32/4233_2.png) [@Aasemoon](https://help.nextcloud.com/u/Aasemoon)\
**Post date:** [May 24, 2017, 4:16pm UTC](https://help.nextcloud.com/t/removing-index-php-from-the-nextcloud-uri/13055/5 "2017-05-24T16:16:53Z")

</div>

Thanks! =) Tried adding this to .htaccess, doesn’t look like it’s made a different though.  
Any other ideas?

---

<div class="post-metadata">

**Author:** ![Aasemoon](https://help.nextcloud.com/user_avatar/help.nextcloud.com/aasemoon/32/4233_2.png) [@Aasemoon](https://help.nextcloud.com/u/Aasemoon)\
**Post date:** [May 24, 2017, 6:02pm UTC](https://help.nextcloud.com/t/removing-index-php-from-the-nextcloud-uri/13055/6 "2017-05-24T18:02:47Z")

</div>

Oh haha I just figured it out! It was in fact the bloody FastCGI… mod\_php isn’t actually enabled when using FastCGI. I switched to php.ini and problem solved.

I’ve seen this question several times around the web, I hope someone else can use this.

Cheers!

---

<div class="post-metadata">

**Author:** ![cbr](https://help.nextcloud.com/letter_avatar/cbr/32/6_22734026db12803ebb3e059622ac3534.png) [@cbr](https://help.nextcloud.com/u/cbr)\
**Post date:** [April 23, 2018, 1:32pm UTC](https://help.nextcloud.com/t/removing-index-php-from-the-nextcloud-uri/13055/7 "2018-04-23T13:32:16Z")

</div>

I’m not sure if it is the right way to do it. But, I have added the below lines in the **nextcloud.conf** file under **\<Directory /var/www/nextcloud/\>** apart from occ update command

```
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

```

This worked for me. But it may not be useful if nextcloud is installed in a shared hosting

---

<div class="post-metadata">

**Author:** ![Witzker](https://help.nextcloud.com/user_avatar/help.nextcloud.com/witzker/32/36775_2.png) [@Witzker](https://help.nextcloud.com/u/Witzker)\
**Post date:** [December 23, 2018, 7:17pm UTC](https://help.nextcloud.com/t/removing-index-php-from-the-nextcloud-uri/13055/8 "2018-12-23T19:17:50Z")

</div>

Hi  
I do not understand the solution  
where to switch what

can I get a detailed explanation for dummy

---

<div class="post-metadata">

**Author:** ![brt](https://help.nextcloud.com/user_avatar/help.nextcloud.com/brt/32/420_2.png) [@brt](https://help.nextcloud.com/u/brt)\
**Post date:** [November 17, 2019, 11:13pm UTC](https://help.nextcloud.com/t/removing-index-php-from-the-nextcloud-uri/13055/9 "2019-11-17T23:13:38Z")

</div>

sorry for necrobumping this thread, but it may help others, facing the same problem:

- mod\_env enabled
- mod\_rewrite enabled
- in config.php: `'htaccess.RewriteBase' => '/',`
- .htaccess was successfully written by occ maintenance:update:htaccess

but still having /index.php/

i was able to “ **quickfix** ” this by setting **`'htaccess.IgnoreFrontController' => true`** in my config.php (see: [Apache rewrite to remove index.php](https://help.nextcloud.com/t/apache-rewrite-to-remove-index-php/658/44))

but finally, after some investigation, i found the “real” cause: **nextcloud is not detecting working mod\_env when php-fpm was running as fcgi**!

background: with php running as cgi, every request was served via redirect which adds `REDIRECT_` to all the variable-names set by SetEnv, like:

`SetEnv front_controller_active true`

becomes: `[REDIRECT_front_controller_active] => true`

it seems the nextcloud-check does not take this into account.

the **proper solution** was enabling the apache Module proxy\_fcgi and changing the SetHandler like this:

```
<FilesMatch "\.php[345]?$">
         SetHandler "proxy:unix:/var/lib/php7-fpm/cloud.sock|fcgi://localhost"
</FilesMatch>

```

i also removed the lines for Action, Alias, and FastCgiExternalServer regarding the former php7-fcgi handler as they were no longer used.

and voila! the variablenames set via SetEnv in .htaccess stay unchanged, nextcloud recognises the front\_controller\_active variable -\> **/index.php/ is gone, without setting htaccess.IgnoreFrontController**

---

<div class="post-metadata">

**Author:** ![GabrielKlein](https://help.nextcloud.com/user_avatar/help.nextcloud.com/gabrielklein/32/11920_2.png) [@GabrielKlein](https://help.nextcloud.com/u/GabrielKlein)\
**Post date:** [February 8, 2020, 9:57pm UTC](https://help.nextcloud.com/t/removing-index-php-from-the-nextcloud-uri/13055/10 "2020-02-08T21:57:51Z")

</div>

I spent some time trying to find where the issue come from.

As my nextcloud is in a specific folder, I had the following configuration in my apache2.

```auto
<Directory /home/mynextcloud>
	Options Indexes FollowSymLinks
	AllowOverride None
	Require all granted
</Directory>

```

I just set AllowOverride to

```auto
AllowOverride All

```

And fixed the problem.

---

<div class="post-metadata">

**Author:** ![drewjosh](https://help.nextcloud.com/user_avatar/help.nextcloud.com/drewjosh/32/30401_2.png) [@drewjosh](https://help.nextcloud.com/u/drewjosh)\
**Post date:** [December 13, 2020, 8:36pm UTC](https://help.nextcloud.com/t/removing-index-php-from-the-nextcloud-uri/13055/11 "2020-12-13T20:36:27Z")

</div>

@clouduser adding the line to my config.php and updating the htaccess worked for me. I didn’t even need to restart the server (I can’t anyway because I am on web hosting). Cheers!

---

<div class="post-metadata">

**Author:** ![Tomvanwaas](https://help.nextcloud.com/letter_avatar/tomvanwaas/32/6_22734026db12803ebb3e059622ac3534.png) [@Tomvanwaas](https://help.nextcloud.com/u/Tomvanwaas)\
**Post date:** [December 28, 2020, 4:04pm UTC](https://help.nextcloud.com/t/removing-index-php-from-the-nextcloud-uri/13055/12 "2020-12-28T16:04:24Z")

</div>

Hi,

Since you are also a web user, could you explicitly name all of the steps that you have gone through? Specifically, it would be useful for me where you have installed your nextcloud (e.g. [domain.com/nextcloud](http://domain.com/nextcloud)) and then explicitly mention the changes to the config.php file and .htaccess file and at what points during the installation process you have made them. That would be much appreciated!

---

<div class="post-metadata">

**Author:** ![DadeMurphy](https://help.nextcloud.com/user_avatar/help.nextcloud.com/dademurphy/32/35920_2.png) [@DadeMurphy](https://help.nextcloud.com/u/DadeMurphy)\
**Post date:** [February 22, 2021, 8:48pm UTC](https://help.nextcloud.com/t/removing-index-php-from-the-nextcloud-uri/13055/13 "2021-02-22T20:48:39Z")

</div>

Hi, same problem for me. In my case: dummy mode.

Cheers  
DM

---

<div class="post-metadata">

**Author:** ![drewjosh](https://help.nextcloud.com/user_avatar/help.nextcloud.com/drewjosh/32/30401_2.png) [@drewjosh](https://help.nextcloud.com/u/drewjosh)\
**Post date:** [February 26, 2021, 2:26pm UTC](https://help.nextcloud.com/t/removing-index-php-from-the-nextcloud-uri/13055/14 "2021-02-26T14:26:10Z")

</div>

@Tomvanwaas and @DadeMurphy

The solutions mentioned above can also be found in the nextcloud docs: [Proxy Configurations](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#proxy-configurations)

1. Add this line to [root folder of nextcloud]/config/config.php:

`'htaccess.RewriteBase' => '/',`

Advice on parameter:

> In a standard Apache setup this usually equals the folder that Nextcloud is accessible at. So if Nextcloud is accessible via “[https://mycloud.org/nextcloud”](https://mycloud.org/nextcloud%E2%80%9D) the correct value would most likely be “/nextcloud”. If Nextcloud is running under “[https://mycloud.org/”](https://mycloud.org/%E2%80%9D) then it would be “/”.

1. Login to your server via SSH and navigate to your nextcloud folder

2. Run the following command to update your .htaccess file:  
`occ maintenance:update:htaccess`  
(on my web hosting server I need to run it like this: php occ maintenance:update:htaccess)

You can update the .htcaccess file in nextcloud root folder manually but I only recommend that when you really know what you are doing.

If you don’t have access to your server via SSH, try [running occ commands via web interface](https://help.nextcloud.com/t/how-to-use-occ-commands-on-a-shared-hosting-without-ssh-access/46133).

Let me know if this was clear enough. Cheers 😁

---

<div class="post-metadata">

**Author:** ![MyBlood](https://help.nextcloud.com/user_avatar/help.nextcloud.com/myblood/32/67605_2.png) [@MyBlood](https://help.nextcloud.com/u/MyBlood)\
**Post date:** [November 16, 2021, 7:56am UTC](https://help.nextcloud.com/t/removing-index-php-from-the-nextcloud-uri/13055/15 "2021-11-16T07:56:02Z")

</div>

> [@clouduser](#):
>
> Update htaccess with the occ command  
> `sudo -u apache php occ maintenance:update:htaccess`

Greetings!

What should I do if I get this error when I run this command?  
 ![image](https://help.nextcloud.com/uploads/default/original/3X/c/c/ccf7353a53fafe6d6cf2683ff2c58bf5e2f9ba79.png)

---

<div class="post-metadata">

**Author:** ![devnull](https://help.nextcloud.com/user_avatar/help.nextcloud.com/devnull/32/27793_2.png) [@devnull](https://help.nextcloud.com/u/devnull)\
**Post date:** [November 16, 2021, 10:10am UTC](https://help.nextcloud.com/t/removing-index-php-from-the-nextcloud-uri/13055/16 "2021-11-16T10:10:48Z")

</div>

Perhaps you use an old php version. Read [this](https://help.nextcloud.com/t/php-occ-db-add-missing-indices/90967).

---

<div class="post-metadata">

**Author:** ![Lulucmy](https://help.nextcloud.com/user_avatar/help.nextcloud.com/lulucmy/32/45168_2.png) [@Lulucmy](https://help.nextcloud.com/u/Lulucmy)\
**Post date:** [August 14, 2022, 3:36pm UTC](https://help.nextcloud.com/t/removing-index-php-from-the-nextcloud-uri/13055/17 "2022-08-14T15:36:04Z")

</div>

I had the same problem on my Nextcloud instance (on o2switch), this is the only solution that worked. Thanks 🙂

---

<div class="post-metadata">

**Author:** ![afzl](https://help.nextcloud.com/user_avatar/help.nextcloud.com/afzl/32/50073_2.png) [@afzl](https://help.nextcloud.com/u/afzl)\
**Post date:** [March 27, 2023, 6:05am UTC](https://help.nextcloud.com/t/removing-index-php-from-the-nextcloud-uri/13055/18 "2023-03-27T06:05:01Z")

</div>

Thanks a lot. It worked for me even my NextCloud instance run in HestiaCP.

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 2, 2024, 1:37pm UTC](https://help.nextcloud.com/t/removing-index-php-from-the-nextcloud-uri/13055/19 "2024-12-02T13:37:12Z")

</div>


