Azure/wordpress-linux-appservice

Front Door Rule - Upper & Lower Case File Names within Storage Blob

Closed this issue · 4 comments

Is there a rule set that can be applied to Azure Front Door to manage upper and lower case file names within Storage Blob? It seems that file names are case-sensitive and must be an exact match.

For example:

Uppercase in the Request URL:

  • URL Request: /file-name.pdf
  • Storage Blob File Name: File-Name.pdf

Lowercase in the Request URL:

  • URL Request: /File-Name.pdf
  • Storage Blob File Name: file-name.pdf

In both cases, you would receive the following error message:

<Error> <Code>BlobNotFound</Code> <Message>The specified blob does not exist. RequestId:4b4a080f-601e-005e-4847-2323232323 Time:2024-08-22T03:55:49.6483070Z</Message> </Error>

Is there a way to address this issue so that Azure Front Door can handle case discrepancies, such as when the request URL is uppercase but the Storage Blob file name is lowercase, or vice versa? Additionally, what should be done when the file name is in all uppercase, e.g., FILE-NAME.pdf?

@KloudstackHosting Azure Front Door doesn't support changing case for an incoming URL request but only allows pattern match and replace type of functions.

However, for achieving case insensitive querying of wordpress media, you can explore WordPress extensions that convert any new media files to lowercase before uploading (This can be done by adding a simple hook to 'wp_handle_upload_prefilter' wordpress filter) and updating existing media file URLs to lowercase.

So this approach would only work if the images had been uploaded to WordPress by the media upload or placed under the uploads folder. But not if images had been uploaded to Azure blob, it would not apply the conversion.

In general, uploading to Azure blob directly is not recommended since it won't be picked up by WordPress as a media file even though it is present in the blob storage. This is because WordPress also needs to a reference to the media file in the database which wouldn't happen in this case.

If you're looking at converting all URLs to lowercase, then uploading to WordPress by media file upload will automatically upload it to Azure blob storage as well.

Closing this since you can achieve case insensitive Blob Storage URLs by adding a WordPress hook to convert media files to lowercase name.