I run a NextCloud instance and one of the little paper cuts that bug me is that I can’t create a custom link to a publicly accessible folder.
When a shared folder is created in the NextCloud file manager a random URL is created that has the following form:
This is not easy to remember when I want to give out a link to a file I want to share.
I found an easy way to fix this so that
https://example.comm/public will redirect to
https://example.comm/index.php/s/catTLcZxBbgSjXA using Apache2’s mod_rewrite.
The example here is for Apache2 but you will be able to do something similar with NGINX.
All you need to do is to open the
VirtualHost file for your NextCloud instance and add the following lines:
RewriteEngine on RewriteRule "^/public$" "https://example.com/index.php/s/catTLcZxBbgSjXA" [R]
This will redirect
https://example.comm/index.php/s/catTLcZxBbgSjXA. You need to edit this to fit your requirements.
You need to put this in the correct location in your
VirtualHost file. You can see it here in a full
<VirtualHost 184.108.40.206:443> DocumentRoot /var/www/nextcloud ServerName example.com <Directory /var/www/nextcloud/> Options +FollowSymlinks AllowOverride All <IfModule mod_dav.c> Dav off </IfModule> SetEnv HOME /var/www/nextcloud SetEnv HTTP_HOME /var/www/nextcloud </Directory> SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf CustomLog /var/log/apache2/example.com.access.log common ErrorLog /var/log/apache2/example.com.error.log RewriteEngine on RewriteRule "^/public$" "https://example.com/index.php/s/catTLcZxBbgSjXA" [R] </VirtualHost>
After you’ve added those lines restart Apache2:
systemctl restart apache2.service
And test it from an anomalous browser tab.