htacces re-write url uppercase letters to loweercase

I need to add a rule to my htaccess file that re-writes all uppercase letters in a url to lower case.  I tried to follow the instructions on this page to no avail:
https://www.askapache.com/htaccess/rewrite-uppercase-lowercase/

Can anyone help?

my htaccess
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://MYSITE.com/$1 [R,L]

#For Elegant Theme Support 2/28/2018 - JNL
#<IfModule mod_substitute.c>
#SubstituteMaxLineLength 20M
#</IfModule>

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Open in new window

LVL 9
Robert GranlundAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
The obvious question is why?
A reason could be that on Linux systems case matters and you want to make sure that misspelled url's go to where they need to.

My personal preference would be to setup a custom error handler and do the checking in code.

Get URL
convert case
Add url parameter to say it has been converted
Redirect

Second time around - check to see if url parameter exists - if not do the above else standard error page.
Robert GranlundAuthor Commented:
@Julian: "The obvious question is why?"
I was asked to.  I believe that they believe it is effecting their SEO. Plus, I would like to understand it.
I am going to keep looking into answers. Thanks though for the suggestions.
Julian HansenCommented:
I believe that they believe it is effecting their SEO
That I don't understand.
As far as I know Google now treats capital's and non-capitals the same.

Having said that - even if they didn't - the spiders only see the public facing URL - not the URL that is re-written - so the question is - if the target URL needs to be different why not change the sites actual URL's.

Failing that I stand by my earlier suggestion - do this in code - not in .htaccess.
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

NerdsOfTechTechnology ScientistCommented:
I would use the 2nd approach if you have access to the httpd.conf file (it's cleaner and faster).

https://www.askapache.com/htaccess/rewrite-uppercase-lowercase/
Robert GranlundAuthor Commented:
What am I doing wrong?  The way I have it below breaks the site:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://MYSITE.com/$1 [R,L]

#For Elegant Theme Support 2/28/2018 - JNL
#<IfModule mod_substitute.c>
#SubstituteMaxLineLength 20M
#</IfModule>

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# If there are caps, set HASCAPS to true and skip next rule
RewriteRule [A-Z] - [E=HASCAPS:TRUE,S=1]

# Skip this entire section if no uppercase letters in requested URL
RewriteRule ![A-Z] - [S=28]

# Replace single occurance of CAP with cap, then process next Rule.
RewriteRule ^([^A]*)A(.*)$ $1a$2
RewriteRule ^([^B]*)B(.*)$ $1b$2
RewriteRule ^([^C]*)C(.*)$ $1c$2
RewriteRule ^([^D]*)D(.*)$ $1d$2
RewriteRule ^([^E]*)E(.*)$ $1e$2
RewriteRule ^([^F]*)F(.*)$ $1f$2
RewriteRule ^([^G]*)G(.*)$ $1g$2
RewriteRule ^([^H]*)H(.*)$ $1h$2
RewriteRule ^([^I]*)I(.*)$ $1i$2
RewriteRule ^([^J]*)J(.*)$ $1j$2
RewriteRule ^([^K]*)K(.*)$ $1k$2
RewriteRule ^([^L]*)L(.*)$ $1l$2
RewriteRule ^([^M]*)M(.*)$ $1m$2
RewriteRule ^([^N]*)N(.*)$ $1n$2
RewriteRule ^([^O]*)O(.*)$ $1o$2
RewriteRule ^([^P]*)P(.*)$ $1p$2
RewriteRule ^([^Q]*)Q(.*)$ $1q$2
RewriteRule ^([^R]*)R(.*)$ $1r$2
RewriteRule ^([^S]*)S(.*)$ $1s$2
RewriteRule ^([^T]*)T(.*)$ $1t$2
RewriteRule ^([^U]*)U(.*)$ $1u$2
RewriteRule ^([^V]*)V(.*)$ $1v$2
RewriteRule ^([^W]*)W(.*)$ $1w$2
RewriteRule ^([^X]*)X(.*)$ $1x$2
RewriteRule ^([^Y]*)Y(.*)$ $1y$2
RewriteRule ^([^Z]*)Z(.*)$ $1z$2

# If there are any uppercase letters, restart at very first RewriteRule in file.
RewriteRule [A-Z] - [N]

RewriteCond %{ENV:HASCAPS} TRUE
RewriteRule ^/?(.*) /$1 [R=301,L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Open in new window

NerdsOfTechTechnology ScientistCommented:
The change case rewrites have to be above all other rewrites. However, method #2 and #3 in that above link is way cleaner and less risky.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.