Open bunglegrind opened 5 years ago
So, the issue concerns the PHP constant DIRECTORY_SEPARATOR which you are using in the RewriteCond rule in the getDirectoryMatch() methods. You should use a forward slash since you're matching a uri not a file path.
Could you make a PR for this? That would be really nice.
fine, but I need a clarification:
RewriteCond %{REQUEST_URI} !.*\/sites\/[0-9]+\/.*
1) what is the purpose of the rule above? 2) why are you escaping the forward slashes?
Cheers.
Created. But there may be similar issues...
Yes there are...almost every time you create a path.
http://cmljnelson.blog/2018/07/26/which-way-do-your-slashes-face/
Probably wp_normalize_path should fix the issue (at least for the paths, concerning the uris replacing DIRECTORY_SEPARATOR with '/' is the right fix)
On a clean install, WP 5.2, with UAM latest stable, if I lock files with locked directory type option Wordpress selected, the locking does not work. Specifically, the rule created by UAM:
RewriteCond %{REQUEST_URI} ^.*\[0-9]{4}\[0-9]{2}.*$
in .htaccess does not match the uri. (example: http://wp.localhost/wp-content/uploads/2019/05/doe.pdf
Complete .htaccess:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_URI} !.*\/sites\/[0-9]+\/.* RewriteCond %{REQUEST_URI} ^.*\[0-9]{4}\[0-9]{2}.*$ RewriteRule ^([^?]*)$ /index.php?uamfiletype=attachment&uamgetfile=$1 [QSA,L] RewriteRule ^(.*)\?(((?!uamfiletype).)*)$ /index.php?uamfiletype=attachment&uamgetfile=$1&$2 [QSA,L] RewriteRule ^(.*)\?(.*)$ /index.php?uamgetfile=$1&$2 [QSA,L] </IfModule>
In Settings->media "Organize my uploads into month- and year-based folders" is checked.
The problem is, in addition to the wrong regexp expression, that the "wordpress" option only checks the uri against the regexp expression, instead of checking all the media database to verify if the requested file is matching one of the WP media.
I kindly suggest you to rephrase the sentence above accordingly