0

My site is seoitc.com, we are using joomla for this site, but have 1 problem when i try auto redirect to anypage that show error: Warning: Cannot modify header information - headers already sent by ().
I tried change redirect to use js but cant use same status(302,303...) same as in php. Please help to fix this problem please.
Thanks!

3
Contributors
16
Replies
18
Views
4 Years
Discussion Span
Last Post by diafol
0

Your header() is declared after output to the page. Ensure that no html , whitespace or php-derived html or php errors are output before the header()

0

Thanks for replly, i write 1 function for redirect then i call it back at other functions so that showing this error.

0

Ok. Unless you post your code, I can't see how we can be of further assistance. It would be guesswork on our part.

0
function wp_redirect($location, $status = 302) {
    global $is_IIS;

    $location = apply_filters('wp_redirect', $location, $status);
    $status = apply_filters('wp_redirect_status', $status, $location);

    if ( !$location ) // allows the wp_redirect filter to cancel a redirect
        return false;

    $location = wp_sanitize_redirect($location);

    if ( !$is_IIS && php_sapi_name() != 'cgi-fcgi' )
        status_header($status); // This causes problems on IIS and some FastCGI setups

    header("Location: $location", true, $status);
    ?>
    <script type="text/javascript">
        //window.location = "<?php echo $location;?>";
    </script>
    <?php

}

Im using wordpress, demo on http://www.codeit.vn/wp-admin/, please help .
Thanks!

0

I can't see the point of the js - does it ever get implemented? The header() or return false will stop the function before the js is reached.

The code seems OK, but I don't know what happens with the external function calls:

 $status = apply_filters('wp_redirect_status', $status, $location);
 status_header($status);

If an error is returned, then that could cause php output, which will kill the header().

Also, if you have other code before this in your page, there may be output from that.

0

I tried config show all errors+ warning in phpini but just have that warning, i dont see any other error, on frontend thats working fine.

0

just curious, what happens when you put an

exit();

after the header() call?

If that doesn't solve the problem then put an

exit("End");

just before the header call and then view source after you run it to see if there is any white space or characters prior to the word "End" in the html source. If there is then you are, or something is, outputting content to the page prior to the header redirect attempt which means that headers have already been sent to the browser and a 302 is no longer possible at that point.

Edited by R0bb0b

0

Warning: Cannot modify header information - headers already sent by ()

Does it give a line number for the headers sent by... ? If so, print the block of code to which it belongs.

0

output started at /mnt/stor12-wc2-dfw1/554928/www.codeit.vn/web/content/wp-content/themes/Tersus/functions.php:1

I tried print exit('End') and its showing 1 <br /> at top.

0

output started at /mnt/stor12-wc2-dfw1/554928/www.codeit.vn/web/content/wp-content/themes/Tersus/functions.php:1

That's your answer. Do you have whitespace before the <?php tag? Or is there any html on that first line in the file?

0

I checked all files, i add all close tag ?>, dont have anyfile there is any html at first line in the file. Do i need to remove comment?

0

I fixed, i remove all speace and change encode to utf8, thats working fine.
Thanks for your help, if you have any client want do seo please introduce us we will do free 1month for you.
Thanks again!

0

Thanks. BTW - I don't know if it's my connection, but your site is taking a very long time to load.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.