Forum Moderators: phranque
/Tension.phpshould be/tension.php RewriteRule (.+)\.php /$1.php [NC,R=301,L]but that results in the incorrectly-cased original.
<FilesMatch "^[A-Z].+\.php$">
CheckSpelling on
CheckCaseOnly on
</FilesMatch>
RewriteCond expr "tolower(%{REQUEST_URI}) =~ /(.*)/"
RewriteRule [A-Z] %1 [R=301,L]
RewriteMap lc int:tolower
But, as usual, don't use their redirect example verbatim. Among other things: Are all the problem URLs at the root, or do you need to deall with directories as well?
[if] only one document is found that "almost" matches the request, then it is returned in the form of a redirection response.And that's not very helpful, because #1 it doesn't specify 301 vs. 302, and more seriously #2 Apache often says “redirect” when referring to internal activity, or what we try to call--with double markedness--an internal rewrite. I guess you can't really blame them, considering things like headers in REDIRECT_ which obviously refer to internal activity on the present request, or REDIRECT_STATUS in php. But it's confusing.
actual cases in this instance resolve to the initial letter of the URI
[edited by: phranque at 11:43 pm (utc) on Mar 7, 2021]
RewriteCond expr "tolower(%{REQUEST_URI}) =~ /(.*)/"
RewriteRule [A-Z] %1 [R=301,L]
RewriteCond expr "tolower(%{REQUEST_URI}) =~ /(.*)/"
RewriteRule [A-Z] https://www.example.com%1 [R=301,L] actual cases in this instance resolve to the initial letter of the URI
RewriteCond expr "tolower(%{REQUEST_URI}) =~ /(.*)/"
RewriteRule ^[A-Z] https://www.example.com%1 [R=301,L]
RewriteRule ^[A-Z]\w+(-[A-Z]?\w+)?\.php /$1\.php [R=301,L] RewriteCond expr "tolower(%{REQUEST_URI}) =~ /(.*)/"
RewriteRule ^[A-Z] https://www.example.com%1 [R=301,L] your suggestion [A-Z]\w+\.php does not change the caseIt's not supposed to. That's just the pattern for the capture: anything that contains an upper-case letter will be subject to this rule.
Why would this method be different to any other external redirect?If the redirect target doesn't specify exact hostname and protocol, the server will use whatever was in the request--which might well be wrong too. That would lead to a redirect chain, unnecessary work for the server and possibly delay for the end user if they've got a slow connection.