0

If i enter on my domain with the adress: "www.domain.com" it works but if i do it like "domain.com" it doesn't, I get this message:

Warning: Cannot modify header information - headers already sent by (output started at /home/eventtou/public_html/index.php:2) in /home/eventtou/public_html/wp-includes/pluggable.php on line 1228

here is index.php

<?php
/**
 * Front to the WordPress application. This file doesn't do anything, but loads
 * wp-blog-header.php which does and tells WordPress to load the theme.
 *
 * @package WordPress
 */

/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );

and here are lines 1197 - 1232 of my pluggable.php

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

    /**
     * Filter the redirect location.
     *
     * @since 2.1.0
     *
     * @param string $location The path to redirect to.
     * @param int    $status   Status code to use.
     */
    $location = apply_filters( 'wp_redirect', $location, $status );

    /**
     * Filter the redirect status code.
     *
     * @since 2.3.0
     *
     * @param int    $status   Status code to use.
     * @param string $location The path to redirect to.
     */
    $status = apply_filters( 'wp_redirect_status', $status, $location );

    if ( ! $location )
        return false;

    $location = wp_sanitize_redirect($location);

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

    header("Location: $location", true, $status);

    return true;
}
endif;

what can I do to solve this ? thank you in advance!

statosdotcom
  • 3,109
  • 2
  • 17
  • 40
Adi
  • 63
  • 10
  • try with use of ob_start() on the top of page once – Deep Kakkar Mar 02 '16 at 13:56
  • 7
    possible duplicate of [How to fix Headers already sent error in PHP](http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php) – Funk Forty Niner Mar 02 '16 at 13:56
  • Check with your ISP if your host is configured to answer `domain.com` requisitions. It's a kind of subdomain, not automatically configured when you contract a host service. If the host is owned by you, I think this matters to the httpd.conf file. – statosdotcom Mar 02 '16 at 14:08

1 Answers1

0

If you run an apache, place a .htaccess file in your root directory of the website or insert the part below in an existing .htaccess

<IfModule mod_rewrite.c>
  ##-- Initialize and enable rewrite engine
  ##-- Documentation http://httpd.apache.org/docs/misc/rewriteguide.html
  RewriteEngine On

  ##-- set the following line like e.g.: RewriteBase /myfolder/
  RewriteBase /
  RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
</IfModule>

Then all accesses to domain.tld are redirected to www.domain.tld

This doesn't really solve your problem in the code. But from SEO standpoint it is a good idea anyway to prevent you from duplicate content. And becasue only www is accessed, the problem doesn't matter any more.

Bonsai
  • 11
  • 1