Q:

How to redirect URLs that contain uppercase letters to another site

Is there any .htaccess rule to redirect a URL that has uppercase letters to another URL / site?
for example :
/Abcgdr

or,
/aaaAbcgfr

redirect to example.com

A:

This is as much a regular expression (regex) question than Apache config, the regex [A-Z] (a character class containing the range A to Z) matches any uppercase letter. Regex are case-sensitive by default, so this won't match lowercase letters.
Using a mod_alias RedirectMatch directive you can do the following in .htaccess:
RedirectMatch 302 [A-Z] https://example.com/

This matches any uppercase letter in the URL-path part of the URL and redirects (302) to https://example.com/.

However, if you have existing mod_rewrite directives, you should consider using mod_rewrite instead. For example, near the top of your .htaccess file:
RewriteEngine On
RewriteRule [A-Z] https://example.com/ [R=302,L]

This does the same as the mod_alias RedirectMatch directive above.

