0

I was just facing the issue in Magento. If we use uppercase letters as request path.

Ex.

Request path: en-US/store-locator
Target path: stores/usa

Now if i try to open url as http://MY_SITE_BASE_URLS/en-US/store-locator/ then it doesn't redirect to Target URL.

But if i change uppercase to lowercase in request path

Ex.

Request path: en-us/store-locator
Target path: stores/usa

Now it works.

I have thousands of URL with uppercase in request path.

Any suggestion??

2 Answers 2

1

If no other solutions i get then i will end up with below solution

$rewrite_model = Mage::getModel('core/url_rewrite')->getCollection();
    foreach ($rewrite_model as $single_rewrite):
       if(preg_match('/[A-Z]/', $single_rewrite->getRequestPath())){
       $single_rewrite->setRequestPath(strtolower($single_rewrite->getRequestPath()))->save();
        }
    endforeach;    

This code will replace all request paths having uppercase letters into the lowercase letters.

2
  • Where do you add this code?
    – Nathan
    Commented Jul 15, 2016 at 2:55
  • You can create a test.php file in root directory Or add it in any phtml ex. header.phtml for one time Commented Jul 16, 2016 at 14:10
0

The bug comes from changements made in app/code/core/Mage/Core/Model/Resource/Url/Rewrite.php

$path = array($path);                          => $path = array(strtolower($path));
$pathBind['path' . $key] = $url;               => $pathBind['path' . $key] = strtolower($url);
$mapPenalty = array_flip(array_values($path)); => $mapPenalty = array_change_key_case(array_flip(array_values($path)));

As proposed here a good solution is to apply to following update request on the database: UPDATE core_url_rewrite SET request_path = LOWER(request_path)

Another solution is to complete the changements made in app/code/core/Mage/Core/Model/Resource/Url/Rewrite.php replacing also the 2 occurences of $item['request_path'] by strtolower($item['request_path'])

Best regards,
Olivier Blanc, Web Developper

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.