Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8328323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:24:09+00:00 2026-06-09T01:24:09+00:00

I need to rewrite a specific word to lowercase if it has an uppercase

  • 0

I need to rewrite a specific word to lowercase if it has an uppercase letter in it but not if it is entirely lowercase (if it matched that it would cause an infinite loop).

I came up with this but am confused as to why it is not working:

# /MaTcHeD to matched
RewriteCond %{REQUEST_URI} ^(?i)matched(\/.*)?$
RewriteRule ^[a-z]*[A-Z]+[^\/]*(\/.*)?$ /matched$1 [R=301,L]

To me this says if url is “matched” or “Matched” or “mAtched” or “MAtched” etc. then match if there is any lowercase characters ([a-z]) at the beginning of the url followed by any one or more uppercase characters ([A-Z]) followed by any non “/” character then the rest of the url (an optional “/” followed by anything else). If those conditions are true then redirect to the lowercase “/matched”.

I have browsed around and seen many solutions that match ANY word, but that would cause problems since other things are in uppercase. I just need “matched” in any case but all lowercase to redirect to the all lowercase “matched”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T01:24:11+00:00Added an answer on June 9, 2026 at 1:24 am

    You can do a couple of checks to cover this, first check that it isn’t lowercase at all:

    RewriteCond %{REQUEST_URI} !^(.*)/matched(.*)$
    

    Then check if the same would match if case was ignored by using the [NC] flag:

    RewriteRule ^(.*)/matched(.*)$ /$1/matched$2 [R=301,L,NC]
    

    At this point, you know that without case sensitivity, matched matched, but it’s not all lowercase, so you can redirect to all lowercase.


    I am using the match currently in the htaccess level so I do not need the initial “(.*)/”. Using that would not work. “matched” is the first path part after the domain

    Try this then:

    RewriteCond %{REQUEST_URI} !^/matched(.*)$
    RewriteRule ^matched(.*)$ /matched$1 [R=301,L,NC]
    

    The problem is that the %{REQUEST_URI} variable does have a leading slash, but the URI used to match against the RewriteRule doesn’t have one (go figure).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to rewrite this query and I'm not allowed to use a subquery.
I know they do not hold across pattern matches (i.e. you need to rewrite
This might not be possible but before I rewrite part of my application I
I need to take standard incoming urls and rewrite redirect them to target specific
I have a specific file, let's call it 'myfile.abc', that I need to have
I have two conditions that need to be met to do specific things with
I am not sure if Wordpress has API to upload file but what I
I need rewrite this url http://adresa.com/article.php?act=view&id=1113 to http://adresa.com/view/1113 I make it with mod_rewrite in
I need to rewrite an image path on the following URLs: domain.com/system/index domain.com/system/view/12345 domain.com/system/search/term1:/term2:data/term3:/term4:data/term5
I need to rewrite some Python code into PHP (don't hate me, a customer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.