Starting with the title, I am unable to make pretty urls on my nextcloud instantce.
I am running:
Nextcloud version: 28.0.6
Operating system and version: Ubuntu 20.04.6 LTS
Apache or nginx version: Apache/2.4.41
PHP version: PHP 8.3.7
Apache 2 mod_php (NOT php-fpm)
mod env and rewrite are enabled.
config.php:
.htaccess needs to be enabled with AllowOverride
This is the first thing that should be verified. If the AllowOverride directive is set to None then this will disable all .htaccess files. In order to verify this, you must open the Apache configuration file (typically either called httpd.conf or apache.conf) and check that the AllowOverride directive is set to AllowOverride All. If you needed to make changes to your Apache config, remember to save the file and restart Apache. sudo service apache2 restart
Which means /etc/apache2/apache2.conf NEEDS to have AllowOverride All under <Directory /var/www/>.
Good piese of information and advice, thanks to Oblivion. This really needs to be in the tutorial for installing Nextcloud. At least as a verification on things not working with .htaccess configs.
I’m glad you got things working, but I’ve re-looked at the documentation this morning (and also did some testing to confirm in case the docs need an update). I obviously believe you that you got it working, but I think something else may be going on here…
It’s true that using an .htaccess file requires AllowOverride All to be active either at the same level or above as where the .htaccess is located. But there is no need to do AllowOverride Allabove the webroot (/var/www/html). If you need to do so for /var/www it means the config in your nextcloud.conf is not being used or itself is being override for some reason (though there’s nothing technically wrong with doing it there instead). It’s more of an “either/or” situation.
For the first case the .htaccess file shipped with Nextcloud should do this work for you when you’re running Apache. You need to make sure that your Web server is using this file. Additionally, you need the mod_rewrite Apache module installed and AllowOverride All set in your apache2.confor vHost-file to process these redirects.
Are you certain you don’t have overlapping VirtualHost’s or something like that? They may be in entirely different config files. Maybe do this:
These days I just reinstalled apache and php from scratch, with apt remove --purge... commands for these packages, and reconfigured them as per the instructions. The issue is that - as I understand it - if apache2.conf has AllowOverride None on the webroot directoy or above, it will simply not take into consideration the nextcloud.conf file when a2ensite nextcloud.conf is used. Not to mention, .htacces will definetly not be taken into consideration. As you can see, my nextcloud.conf did have the AllowOverwrite directive entered. So, no idea why that did not take effect when using ensite command.
grep -r AllowOverride /etc/apache2:
/etc/apache2/mods-available/userdir.conf: AllowOverride FileInfo AuthConfig Limit Indexes
/etc/apache2/mods-available/alias.conf: AllowOverride None
/etc/apache2/apache2.conf: AllowOverride None
/etc/apache2/apache2.conf: AllowOverride None
/etc/apache2/apache2.conf: AllowOverride All
/etc/apache2/apache2.conf:# AllowOverride None
/etc/apache2/apache2.conf:# for additional configuration directives. See also the AllowOverride
/etc/apache2/sites-available/nextcloud.conf: AllowOverride All
/etc/apache2/sites-available/nextcloud.conf.http: AllowOverride All
/etc/apache2/conf-available/serve-cgi-bin.conf: AllowOverride None
/etc/apache2/conf-available/security.conf:# AllowOverride None
grep -r “/var/www” /etc/apache2:
/etc/apache2/apache2.conf:# not allow access to the root filesystem outside of /usr/share and /var/www.
/etc/apache2/apache2.conf:<Directory /var/www/>
/etc/apache2/sites-available/nextcloud.conf: DocumentRoot /var/www/html/
/etc/apache2/sites-available/nextcloud.conf: <Directory /var/www/html>
/etc/apache2/sites-available/nextcloud.conf.http: DocumentRoot /var/www/html/
/etc/apache2/sites-available/nextcloud.conf.http: <Directory /var/www/html/>
/etc/apache2/sites-available/default-ssl.conf: DocumentRoot /var/www/html
/etc/apache2/sites-available/000-default.conf: DocumentRoot /var/www/html
Does /etc/apache2/sites-enabled contain anything other than nextcloud.conf?
For example, it would possibly be overridden if it happens to include 000-default.conf or nextcloud.conf.http (whatever that file is) and the VirtualHost entries overlap?
Yes, those are all files available in sites-available folder. default-ssl and 000-default are the stock files, but I did use a2dissite for both of them, just to be sure, with a2dissite.