magento Url is not working for first time
<p>when we open a site : <a href="http://ab1.domain.com/" rel="nofollow">http://ab1.domain.com/</a> </p>

<p>for first time in browser, it will redirect to below url</p>

<p><a href="http://ab1.domain.com/://index.php/" rel="nofollow">http://ab1.domain.com/://index.php/</a>? &amp; give <strong>404 Not Found 1</strong></p>

<p><strong>://index.php/?</strong> is adding as suffix. but if we open 2nd time, than its working fine.</p>

<p>its multi-store site, when we disabled all stores also still problem is there.</p>

<p>It was problem with custom module , we are using this module for displaying respective currency based on country.</p>

<p><strong>Data.php</strong></p>

<pre><code>&lt;?php
/**
 * Atwix
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * @category    Atwix Mod
 * @package     Atwix_Ipstoreswitcher
 * @author      Atwix Core Team
 * @copyright   Copyright (c) 2014 Atwix (http://www.atwix.com)
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
/* app/code/local/Atwix/Ipstoreswitcher/Helper/Data.php */
class Atwix_Ipstoreswitcher_Helper_Data extends Mage_Core_Helper_Abstract
{
    const DEFAULT_STORE = 'India';

    /**
     * countries to store relation
     * default is English
     * @var array
     */
    protected $_countryToStore = array(
        'IN' =&gt; 'India',
        'US' =&gt; 'USA',
        'FR' =&gt; 'France',
        'AR' =&gt; 'US dollar [$]',
       // 'BO' =&gt; 'US dollar [$]'




    );

    /**
     * get store view name by country
     * @param $country
     * @return bool
     */
    public function getStoreByCountry($country)
    {
        if (isset($this-&gt;_countryToStore[$country])) {
            return $this-&gt;_countryToStore[$country];
        }
        return self::DEFAULT_STORE;
    }
}
</code></pre>

<p><strong>config.xml</strong></p>

<pre><code>&lt;config&gt;
    &lt;modules&gt;
        &lt;Atwix_Ipstoreswitcher&gt;
            &lt;version&gt;1.0.0&lt;/version&gt;
        &lt;/Atwix_Ipstoreswitcher&gt;
    &lt;/modules&gt;
    &lt;global&gt;
        &lt;helpers&gt;
            &lt;atwix_ipstoreswitcher&gt;
                &lt;class&gt;Atwix_Ipstoreswitcher_Helper&lt;/class&gt;
            &lt;/atwix_ipstoreswitcher&gt;
        &lt;/helpers&gt;
        &lt;models&gt;
            &lt;atwix_ipstoreswitcher&gt;
                &lt;class&gt;Atwix_Ipstoreswitcher_Model&lt;/class&gt;
            &lt;/atwix_ipstoreswitcher&gt;
        &lt;/models&gt;
    &lt;/global&gt;
    &lt;frontend&gt;
        &lt;events&gt;
            &lt;controller_action_postdispatch&gt;
                &lt;observers&gt;
                    &lt;atwix_ipstoreswitcher&gt;
                        &lt;class&gt;atwix_ipstoreswitcher/observer&lt;/class&gt;
                        &lt;method&gt;controllerActionPostdispatch&lt;/method&gt;
                    &lt;/atwix_ipstoreswitcher&gt;
                &lt;/observers&gt;
            &lt;/controller_action_postdispatch&gt;
        &lt;/events&gt;
    &lt;/frontend&gt;
&lt;/config&gt;
</code></pre>

<p><strong>Observer.php</strong></p>

<pre><code>class Atwix_Ipstoreswitcher_Model_Observer
{
    /**
     * redirects customer to store view based on GeoIP
     * @param $event
     */
    public function controllerActionPostdispatch($event)
    {
        $cookie = Mage::getSingleton('core/cookie');
        if ($cookie-&gt;get('geoip_processed') != 1) {
            $geoIPCountry = Mage::getSingleton('geoip/country');
            $countryCode = $geoIPCountry-&gt;getCountry();
            if ($countryCode) {
                $storeName = Mage::helper('atwix_ipstoreswitcher')-&gt;getStoreByCountry($countryCode);
                if ($storeName) {
                    $store = Mage::getModel('core/store')-&gt;load($storeName, 'name');
                    if ($store-&gt;getName() != Mage::app()-&gt;getStore()-&gt;getName()) {
                        $event-&gt;getControllerAction()-&gt;getResponse()-&gt;setRedirect($store-&gt;getCurrentUrl(false));
                    }
                }
            }
            $cookie-&gt;set('geoip_processed', '1', time() + 86400, '/');
        }
    }
}
</code></pre>

<p><strong>Edit</strong></p>

<p>What i tried is i replaced <code>$store-&gt;getCurrentUrl(false)</code> by <code>Mage::getUrl('*/*/*', array('_use_rewrite' =&gt; true, '_forced_secure' =&gt; true))</code> than url problem is solved. but module feature is not working.</p>