Shares link with pretty appearance using apache rewrites


I’m putting up my nextcloud instance to use as a personal cloud solution. I’m very pleased with what I see, I have the cloud serving almost as I wanted.

There is one thing though, that I’m trying to achieve right know without success so far, it must be something quite simple but I just can’t seem to work it out, or maybe I’m just to tired to move on. It is related with sharing folders, and their random naming.

Let’s say I have a domain, named (as original as it can get):

Nextcloud is being served on cname “data”, so now I create a shared link, and it goes out something like:

This works as expected, but I want to give the link to a specific person, and would be nice if it had an easier name, say for instance:

I know there is an App that does rename links, and I believe there is already a feature request around here, but I thought that I could deal with apache doing the job for me and don’t depend on an additional App nor waiting for a new feature.

So for instance I would rewrite:
…/files/work --to–> …/s/wt4HA97SdQkF7CR

And if I add another shared link on my nextcloud, I could rewrite a second one:
…/files/party --to–> …/s/pFsgTE24Ffs3FTA

I could set an expiration date on the link, then if latter on I need to re-share, the name would be different but the apache rewrite rule would make sure the external and easier to remember links would still work (just needed to update the random link part on the rule).

I’ve tried messing around with nextcloud/.htaccess but with no success, by adding for example:
RewriteRule ^files/work$ /s/wt4HA97SdQkF7CR [QSA]

But it doesn’t seem to do it.

Initially I’ve tried adding a specific vhosts file for those rewrites, but also no success, so I’ve thought about using “.htaccess” file.

The file is located on nextcloud root, and contains the following (my test attempt is commented on the last block).

File htaccess here to retain format:

The only change I made to “.htaccess” was the lest lines for the rewrite, which are commented above.

This seems such a simple thing to do, can anyone point me out in the right direction?

Many Thanks.