on localhost redirect works on hostgator error Cannot modify header information (php)
<p>I've this code:</p>

<pre><code>&lt;?php
    //Search logic for Holiday.GE
    $search_variables = $_GET['s']. '+' .$_GET['cat'];
    $var_lang_now = $_GET['lang_current_search'];

        if ($var_lang_now == ru OR $var_lang_now == en) {
            $refering_page = 'http://dev.holiday.ge/' . $var_lang_now . "/";
        } else {
            $refering_page = 'http://dev.holiday.ge';
        }

    //This sends http post to url without curl
    header("Status: 301 Moved Permanently");
    header("Location:$refering_page?s=$search_variables");
    exit;
?&gt;
</code></pre>

<p>on localhost where I was testing it worked fine. But on live server it errors out with:</p>

<pre><code>Warning: Cannot modify header information - headers already sent by (output started at /home/sandrodz/public_html/devholidayge/wp-content/themes/sweetholiday/searchlogic.php:3) in /home/sandrodz/public_html/devholidayge/wp-content/themes/sweetholiday/searchlogic.php on line 15

Warning: Cannot modify header information - headers already sent by (output started at /home/sandrodz/public_html/devholidayge/wp-content/themes/sweetholiday/searchlogic.php:3) in /home/sandrodz/public_html/devholidayge/wp-content/themes/sweetholiday/searchlogic.php on line 16
</code></pre>

<p>15 and 16 are lines before exit;</p>

<p>I tried as suggested in answers, but I get same error!</p>

<pre><code>&lt;?php
ob_start();

    //Search logic for Holiday.GE
    $search_variables = $_GET['s']. '+' .$_GET['cat'];
    $var_lang_now = $_GET['lang_current_search'];

        if ($var_lang_now == ru OR $var_lang_now == en) {
            $refering_page = 'http://dev.holiday.ge/' . $var_lang_now . "/";
        } else {
            $refering_page = 'http://dev.holiday.ge';
        }

    //This sends http post to url without curl
    header("Status: 301 Moved Permanently");
    header("Location:$refering_page?s=$search_variables");
    exit;

ob_end_flush();
?&gt;
</code></pre>
