I installed Nextcloud on my Webfaction web space, and want to remove the "index.php
" in the URL. I followed the instructions here, but then realized that it says:
Furthermore these instructions are only working when using Apache together with the mod_php Apache module for PHP. Other modules like php-fpm or mod_fastcgi are unsupported.
It seems my hoster is using Apache with fastcgi. However, the clean URLs do work – instead of https://example.com/index.php/apps/files/, I can go to https://example.com/apps/files/ and get the correct page. But Nextcloud just goes ahead and inserts the "index.php
" when I navigate around. To be precise, a 303 redirect to the long URL is issued.
Also, this forum entry suggests that it does work with php7 and fastcgi.
How can I get it to stop inserting that? I'm fine with editing the code if neccessary, but my experience with PHP is from the time of mysql_*
APIs, and before classes, so I'm having a hard time finding my way around 🙂 – maybe somebody here already knows a quick fix for this problem.
Best Answer
Add these lines in Nextcloud's
config/config.php
:Then run
occ maintenance:update:htaccess
from the console to update the.htaccess
file.You should see these lines added to the end of
.htaccess
:mod_rewrite
andmod_env
must be enabled on your server for this to work. You might have to restart the server for the changes to kick in.This was successfully tested with a Nextcloud 20.0.4 (stable release) on a regular Web install.