for a multi-site setup we are about to launch a chinese store, which has chinese characters in the base url. Howeverer, using .htaccess to load the correct store view, we receive a "Invalid URI supplied" error log and it also crashes the english view for that store, even though the english view doesn't have any chinese characters in the base_url.

Does anyone know what the problem is?

We are using 1.9.1 CE

Here is what I tried in the htaccess:


I've tried various modules, but all only seem to support url keys for products, categories and cms, but none seemt o address to the base_url issue.

I've tried this module: https://github.com/Minglong/Magento-unicode-URL

and I've also tried this: http://killerwhalesoft.com/blog/magento-unicode-url-key-products-categories-cms-pages/

Sorry, but some recent changes on StackExchange suddenly does not allow me to use chinese characters in the body Body cannot contain -insert-chinese-symbol-.

Please see this link for full code info ..


Can anyone help identify the error with the above trace? Could the error come from the _checkBaseUrl function in /core/Mage/Core/Controller/Varien/Front.php ?


Ok, so I've tried to analyse the lib/Zend/Uri/Http.php file and I placed a log output in the valid() function to see which throws the error. According to the log The error seems to come from the validatePath() function.

When logging with this function I receive the following:

2015-08-17T08:52:40+00:00 DEBUG (7): path : /-chinese-chars-here-/shop/
2015-08-17T08:52:40+00:00 DEBUG (7): pattern : /^(?:\/(?:(?:%[[:xdigit:]]{2}|[A-Za-z0-9-_.!~*'()\[\]:@&=+$,;])*)?)+$/
2015-08-17T08:52:40+00:00 DEBUG (7): status : 0

So I need to edit the regex values so it allows chinese vars - specifically this part of the __construct() function in Http.php:

const CHAR_ALNUM    = 'A-Za-z0-9';
const CHAR_MARK     = '-_.!~*\'()\[\]';
const CHAR_RESERVED = ';\/?:@&=+$,';
const CHAR_SEGMENT  = ':@&=+$,;';
const CHAR_UNWISE   = '{}|\\\\^`';

To make this validation work:

        // Escaped special characters (eg. '%25' for '%')
    $this->_regex['escaped']    = '%[[:xdigit:]]{2}';

    // Unreserved characters
    $this->_regex['unreserved'] = '[' . self::CHAR_ALNUM . self::CHAR_MARK . ']';

    // Segment can use escaped, unreserved or a set of additional chars
    $this->_regex['segment']    = '(?:' . $this->_regex['escaped'] . '|[' .
        self::CHAR_ALNUM . self::CHAR_MARK . self::CHAR_SEGMENT . '])*';

    // Path can be a series of segmets char strings seperated by '/'
    $this->_regex['path']       = '(?:\/(?:' . $this->_regex['segment'] . ')?)+';

    // URI characters can be escaped, alphanumeric, mark or reserved chars
    $this->_regex['uric']       = '(?:' . $this->_regex['escaped'] . '|[' .
        self::CHAR_ALNUM . self::CHAR_MARK . self::CHAR_RESERVED .

    // If unwise chars are allowed, add them to the URI chars class
        (self::$_config['allow_unwise'] ? self::CHAR_UNWISE : '') . '])';
  • can you post the relevant information from your .htaccess
    – SR_Magento
    Commented Jul 27, 2015 at 13:42
  • I've edited the info into the question.
    – tecjam
    Commented Jul 27, 2015 at 13:45
  • okay check this: magento.stackexchange.com/questions/49187/…
    – SR_Magento
    Commented Jul 27, 2015 at 13:46
  • Thanks. I saw this previously, but since no product or categories have special character paths I didn't think this applied to the base_url.
    – tecjam
    Commented Jul 27, 2015 at 13:49
  • I think Magento as a whole doesn't support these types of characters (without modification), someone might chime in with a work around.
    – SR_Magento
    Commented Jul 27, 2015 at 13:55

1 Answer 1


So I've lookup how to the support for Unicode characters in the given Zend Library.

From the PHP docs: Unicode character properties and Pattern modifiers

In Zend/Uri/Http.php you'll need to edit two properties.

  1. const CHAR_ALNUM = '\p{Han}A-Za-z0-9'; Change to add support for Unicode Han
  2. Add a pattern modifier /u in validatePath() public function validatePath($path = null) { if ($path === null) { $path = $this->_path; }

    // If the path is empty, then it is considered valid
    if (strlen($path) === 0) {
        return true;
    // Determine whether the path is well-formed
    $pattern = '/^' . $this->_regex['path'] . '$/u';
    $status  = @preg_match($pattern, $path);
    if ($status === false) {
        #require_once 'Zend/Uri/Exception.php';
        throw new Zend_Uri_Exception('Internal error: path validation failed');
    return (boolean) $status;


I focused on the path section, but the same will go for other sections.

Also, copy the modified file to app/code/local/Zend/Uri/Http.php, this will override the original file and won't be overwritten with a Magento update

  • 2
    Also, copy the modified file to app/code/local/Zend/Uri/Http.php, this will override the original file and won't be overwritten with a Magento update Commented Jan 15, 2016 at 13:16

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.