I'd like to change the case of my query String so that the results page contains the lower case version thereof, for example:

For a search Delicious Pie, instead of the results page being:


I'd like it to read:


As described in this question (Case Sensitive URL Rewrites), it's not possible to set up multiple instances of different case sensitive URL rewrites.

Thus, instead of taking the proposed solution and still being required to do manual rewrites for a variety of different possible cases of search, I'd like to bypass it using a single URL rewrite (all lower case).

Modifying Mage_CatalogSearch_Helper_Data::setQueryText()'s this->_queryText to lower case seems to work, but the result URL still contains the original (non-manipulated) case.

3 Answers 3


The query is served like a GET parameter, so if it's pasted in upper case it will be parsed to the query string uppercase. You can update user's input with JavaScript, like in @harri's answer.

Or add JS to the search input box


But it will only work for user input.

If the query is pasted in as a link, without using form, it still will be upper-cased.

You can try to modify query param in the event controller_front_init_before event, before the URL rewrite takes place.

Alternately, use Apache RewriteMap lower int:tolower or NGINX ngx.arg[1]:lower(), but it's just a guess, did not try myself.

EDIT - Apache's rewrite below:

RewriteEngine on
RewriteMap lowercase int:tolower
RewriteCond %{REQUEST_URI} ^/catalogsearch [NC]
RewriteRule /catalogsearch/(.*?[A-Z]+.*)$ /catalogsearch/${lowercase:$1} [R=301,L]
  • RewriteMap should be added in the server configuration or virtual host configuration. Won't work in the .htaccess Commented Oct 3, 2017 at 12:12

You could try adding the following javascript to site / search phtml file:

document.getElementById("search_mini_form").onsubmit = function() {
  var term;
  term = document.getElementById("search");
  term.value = (term.value.toLowerCase());

I tested this and it works with Magento 1 however not sure if this is quite what you are after. This Will convert all text in search box to lowercase before submit however so the url will always be lowercase when searched from the search form.


I think for this javascript function onkeyup will work for you, this trick always work If use has caps lock on, paste capital letter, manual adding entry by capital letter.

<input id="search" type="search" name="q" value="" class="input-text required-entry" maxlength="128" placeholder="Search entire store here..." autocomplete="off" onkeyup="return searchTextToLower(this);">

Just add onkeyup="return searchTextToLower(this);" in your search text box and write very simple javascript function like this,

function searchTextToLower(searchText)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.