问题原文
原帖链接 · Daniel Lemes · CC BY-SA 4.0
Recently I was forced to migrate from cPanel to CentOS Web Panel and there is a case-sensitive issue with file names, so "filewhatEver.jpg" is not being found in a url "filewhatever.jpg" (had no problem before in cPanel).
This site (there are 4 hosted) .htaccess have only the basic configuration for WordPress sites:
RewriteEngine on
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
mod_rewrite is active (listed in active modules), but when I try:
RewriteMap insensitive tolower:
RewriteRule ^[\/]*(.*)$ /${insensitive:$1} [R,L]
No luck. Edit: gives me a "Internal Server Error".
Any idea?
已采纳解答
原帖链接 · MrWhite · CC BY-SA 4.0
Since the underlying filenames are mixed case, you can't use a rewrite map to convert the request to lowercase as it will still fail to match. (Incidentally, rewrite maps can only be defined in the main server config, not in .htaccess.)
However, you can use mod_speling (one l) to achieve the case-insensitive file matching.
You need to first make sure that mod_speling in enabled on your server. Then add the following directives to your virtual host config (or .htaccess file):
CheckSpelling on
CheckCaseOnly on
Note, however, that there is an additional overhead to using mod_speling and an external redirect is triggered when the file is found. The redirect is necessary for SEO, but will be bad for server performance if you are requesting image resources in mixed case (which is what this looks like?).
I would assume mod_speling must have been enabled by default on your old cPanel server, as this would not have been case-insensitive by default.
mod_speling is really only for incorrectly cased requests from external sites. Any internal requests should really be "fixed" to match the correct case of the underlying file.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
