Crawl Rate - Migrations

How To: Convert And Redirect Uppercase URL Characters To Lowercase

By on 9th May 2023

Reading Time: 2 minutes

  • LinkedIn
  • Twitter
uppercase and lowercase letters

When carry out crawl rate optimisation, one of the fundamental aims is to avoid duplicate URLs being crawled, and a common issue that I’ve come across over the years is a CMS (or user) that has inadvertently created two versions of the same URL with both upper and lower case characters.

For example, the following URLs lead to the same content but would be treated as two separate URLs:

https://organicdigital.co/blog/How-To-Convert-And-Redirect-Uppercase-URL-Characters-To-Lowercase

and

https://organicdigital.co/blog/how-to-convert-and-redirect-uppercase-url-characters-to-lowercase

A URL that is duplicated due to upper and lower case variations is an issue because search engines treat URLs with different cases as separate URLs, even if they lead to the same content. This can cause search engines to index multiple versions of the same page, which can dilute your website’s search engine rankings.

Additionally, if external sites link to different versions of your URL with different cases, it can cause link equity to be split between the different versions, further diluting your website’s authority and ranking potential. Therefore, it’s important to establish a consistent URL structure, preferably using lowercase letters to avoid any potential duplicate content issues.

Best practice would be to avoid any upper case characters and create and serve all links in lower case only.

For some sites, it might be easy to go ahead and convert any URLs and internal links to all lower case, but if this is a CMS or site wide issue, the preferred solution would be to set up redirects rules that 301 redirect any URLs containing upper case characters to their lower case equivalent.

Here is how you do it:

Redirect Uppercase URL Characters To Lowercase using HTACCESS

RewriteEngine On
RewriteRule [A-Z] - [E=HASCAPS:TRUE,S=1]
RewriteRule ![A-Z] - [S=28]
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
RewriteRule [A-Z] - [N]
RewriteCond %{ENV:HASCAPS} TRUE
RewriteRule ^/?(.*) /$1 [R=301,L]

Alternatively, you can try this:

RewriteEngine On
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule ^/?(.*)$ /${lowercase:$1} [R=301,L]

Redirect Uppercase URL Characters To Lowercase using WordPress Plugin

If you don’t have access to the htaccess file via WordPress, then you can use a plugin such as:

WP Force Lowercase URLs

LH Force Lowercase URLs

Redirect Uppercase URL Characters To Lowercase with NGINX

location / {
  rewrite ^/?(.*)$ /${lowercase:$1} [R=301,L]
}

Redirect Uppercase URL Characters To Lowercase with IIS

  1. Open the IIS Manager.
  2. In the left pane, expand the website or application that you want to configure.
  3. In the right pane, double-click on the Url Rewrite Module.
  4. In the Url Rewrite Module dialog box, click on the Rules tab.
  5. Click on the Add Rule button.
  6. In the Add Rule dialog box, select the “Redirect” rule type.
  7. In the URL to Redirect to field, enter the following:

    ${lowercase:{R:0}}
  8. In the Response Type field, select the “Permanent” response type.
  9. Click on the OK button.

Get In Touch

Fill in the form below if you want to enhance your website's organic visibility