I'm getting an invalid uri error when migratin

2019-08-30 04:31发布

问题:

I'm getting the following error when migrating a Magento install to a new Dedicated server

I pretty experienced at cloning and migrating Magento but I can't figure out whats wrong here.

I have checked the new server for compatibility and thats fine..

This error is normally thrown when there is an underscore in the uri . i have tried different subdomains but keep getting the error. I have just migrated the same site to my dev server and it works fine - any ideas ?

Trace:
/home/shushush/public_html/shoponline/magento/lib/Zend/Uri.php(143): Zend_Uri_Http->__construct('http', '//www.shushusho...')
1 /home/shushush/public_html/shoponline/magento/app/code/core/Mage/Core/Model/Store.php(712): Zend_Uri::factory('http://www.shus...')
2 /home/shushush/public_html/shoponline/magento/app/code/core/Mage/Core/Controller/Varien/Front.php(313): Mage_Core_Model_Store->isCurrentlySecure()
3 /home/shushush/public_html/shoponline/magento/app/code/core/Mage/Core/Controller/Varien/Front.php(161): Mage_Core_Controller_Varien_Front->_checkBaseUrl(Object(Mage_Core_Controller_Request_Http))
4 /home/shushush/public_html/shoponline/magento/app/code/core/Mage/Core/Model/App.php(349): Mage_Core_Controller_Varien_Front->dispatch()
5 /home/shushush/public_html/shoponline/magento/app/Mage.php(640): Mage_Core_Model_App->run(Array)
6 /home/shushush/public_html/shoponline/magento/index.php(80): Mage::run('', 'store')
7 {main}

回答1:

Looking at your call stack, it appears this is the method that triggers the error/exception you're seeing

Zend_Uri_Http->__construct

Jumping to the source of that file, I'm guessing (since you didn't include the error text) this is the exception you're seeing.

#File: lib/Zend/Uri/Http.php
protected function __construct($scheme, $schemeSpecific = '')
{
    //...
    if ($this->valid() === false) {
        #require_once 'Zend/Uri/Exception.php';
        throw new Zend_Uri_Exception('Invalid URI supplied');
    }
    //...
}

Taking a look at the definition of the valid method

public function valid()
{
    // Return true if and only if all parts of the URI have passed validation
    return $this->validateUsername()
       and $this->validatePassword()
       and $this->validateHost()
       and $this->validatePort()
       and $this->validatePath()
       and $this->validateQuery()
       and $this->validateFragment();
}

you can see 7 methods Zend/Magento calls to determine if the URI is valid or not. One of these is failing. I'd recommend adding some temporary debugging code to determine which method is returning false

public function valid()
{
    var_dump($this->validateUsername());
    var_dump($this->validatePassword());
    var_dump($this->validateHost());
    var_dump($this->validatePort());
    var_dump($this->validatePath());
    var_dump($this->validateQuery());
    var_dump($this->validateFragment());

    // Return true if and only if all parts of the URI have passed validation
    return $this->validateUsername()
       and $this->validatePassword()
       and $this->validateHost()
       and $this->validatePort()
       and $this->validatePath()
       and $this->validateQuery()
       and $this->validateFragment();
}

Then, once you know that, you can look at the definition of the method that's returning false and determine which characters it's failing on.



回答2:

The problem was due to '_' . It won't recognise the underscore.



标签: magento