Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
Hello you lovely, helpful forum users! Once again, I am stumped by a seemingly simple situation, and our IT team can't suss it out either.

Editors of our site upload mostly .pdf files to the uploads folder, and then generate links to these manually which are embedded within flowchart files to be displayed to the end user - i.e. as hyperlinks to follow to view the .pdf in a new window. The links we generate are, for example:

/couch/uploads/file/patents/ep/exam-report-received/reporting-oa-to-client.PDF

clicking the link takes them to

http://handbook/couch/uploads/file/patents/ep/exam-report-received/reporting-oa-to-client.PDF

as you can see, this example has a capitalised file extension. This seems to happen from time to time when users generate and upload their pdf files. Unfortunately, the links we create are a one-time thing, whereas the .pdf files get updated from time to time. In this example, were I to update the .pdf file, it would almost certainly be by uploading a pdf with a lowercase extension. Alternatively, other users will update my .pdf files with their .PDF files.

This has happened a few times now, and it breaks the hyperlinks because Apache is case sensitive in URLs. The seemingly simple solution to this was to enable the speling module (https://httpd.apache.org/docs/2.4/mod/mod_speling.html) with CheckCaseOnly On

apache2.conf has been set to Directory /var/www/ AllowOverride All

We did this, and if I introduce a capital letter to one of the webpages (i.e. not an upload, but is a templated blog page handled by Couch) it works - it rewrites the url to match the existing page. Unfortunately it does not do the same for the couch uploads.

I have deleted the .htaccess files in couch (that Deny all) because as soon as we implemented mod speling all of the files within /couch/uploads/ returned internal server errors. Deleting the .htaccess files within /couch/ has fixed that.

So I suppose I have 2 questions:

1) is there something I've missed that I need to do to enable the speling module to work for those files in /couch/uploads/ ?
2) does couch have a built in functionality that I've missed / can't find that would achieve this instead?

Thanks in advance!

Anthony
In case it is relevant - the 'AllowOverride' part of the server is as follows:

/etc/apache2/apache2.conf

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Very interesting problem. It originates from changing files without using Couch.. It is hard to find a solution if users are encouraged to do such things like replace files via ftp/filebrowser.
It is quite uncommon to see a post with an issue from not using CouchCMS :lol:

I didn't know of this mod and went to read about it. This apache mod is something of the "last resort" and has its consequences. Couch has files that differ in one character - /couch/upload.php, /couch/uploader.php. This mod seems to create more problems than solve them. Maybe you could enforce a correct way of doing things?
@trendoman, I think the OP seems to be getting this problem despite uploading files through Couch (perhaps @AnthonyW90 would like to comment on this).

As you know, Couch normalizes the names of all files uploaded through it - however, it leaves the file extensions unchanged (so a '.PDF' would go unmodified). I think, if as part of the normalization process, it had also lowercased the extension this problem wouldn't occur.

I have pushed a commit to GitHub that fixes this.
So, @AnthonyW90, assuming the uploads were through the admin-panel, by using the latest commit you should be able to prevent this problem from happening again in the future.

As for the files already uploaded, as @trendoman noted, using Apache mod probably won't be a good idea.
Perhaps it would be better to manually rectify all the names?
Hi both - thank you for such quick responses.

Yes, @KK you are quite correct - users upload the pdf files via Couch. It seems that some users (presumably due to software choices) end up with a capitalised file extension and, as you point out, couch normalizes the file name but not the extension.

Your proposed solution is exactly what is needed - thank you! I will manually normalize those files which already exist, and will update to the latest commit.

Thank you both! :)
5 posts Page 1 of 1