Redirect uppercase to lowercase urls in WordPress

I`ve coming across many crawl errors in google webmastertools, which are due to uppercase letters in urls. So I`ve started to look for an easy solution to redirect uppercase to lowercase urls in WordPress. It took me some time to find the action I needed to hook for, so I`m sharing my solution.

How to redirect uppercase to lowercase urls in WordPress by hooking to the parse_request action

The function have to cover three bases:

  1. Get the request before it is executed.
  2. Check if the request contains upper case letters.
  3. And if it does use 301 redirect to forward it to its lowercase equivallent.
For the first base you just need to hook your function to the parse_request action.  If you`re not familiar how to hook functions to actions visit the WordPress Codex, you can start with the add_action documents and keep on reading the links from there. Learn it, love it and use it! This is one of the biggest advantages of WordPress framework and precisely what gives its flexibility.
add_action('parse_request', 'parseUppercase');
function parseUppercase($wp) {
For the second base you just need a function which checks for uppercase letters in the string. My choice was using a simple RegEx function which returns boolean
function isPartUppercase($string) {
 return (bool) preg_match('/[A-Z]/', $string);
And for the third final base the only good solution to redirect uppercase to lowercase urls in WordPress is wp_redirect. If you`re not familiar with the function you can find useful information about it here.


Download the plugin, paste it in your plugins folder and activate it. As simple as that. Try accessing some urls containing uppercase letters after the installation and voila, no more crawl errors due to uppercase letters in urls.

Plugin Name: Redirect uppercase to lowercase urls in WordPress
Plugin URI:
Description: Fixes 404s in pages caused by uppercase letters in url.
Version: 1.0
Author: Pavel Petrov
Author URI:
License: GPL2
function isPartUppercase($string) {
 return (bool) preg_match('/[A-Z]/', $string);
add_action('parse_request', 'parseUppercase');
function parseUppercase($wp) {
 // only process requests with "lid"
 $query = $wp->query_vars;
 $query = $query['name'];
 $link = site_url().'/'.strtolower($query);
 wp_redirect( $link , 301 );


  • Great solution but I don’t see the download link for the plugin? Also, I was wondering, what’s the advantage of using your method over htaccess? (

    • David Guerreiro

      Hi Tony !

      1) – You can create a folder on the plugin folder with the name ‘redirect’ and them copy and paste that code on the plugin main file (which should have the same name as the plugin has, ‘redirect.php’).

      2) – One of the advantages of this solution is that not everybody feels comfortable modifying the .htaccess file as it can cause several problems if something goes wrong there. Also this solution could be applied if your server is not an apache server.

      Hope this could be helpful !