0

I am playing with dynamic header titles, descriptions and canonical.

I am having some trouble explaining and figuring out what is going on here.

I am copying the exact same sample as below into my existing live website, but for some reason on my live website it does not replace the strings as it does in the testing sample?

Is there anything that can disturb the outcome of the script?

Testing

<html lang="da">
    <head>
        <!-- Title -->
        <title>%TITLE%</title>

        <!-- META -->
        <meta name="description" content="%DESCRIPTION%">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">

        <link rel="canonical" href="%CANONICAL%"/>
        <!-- GOOGLE+ -->
        <meta itemprop="name" content="TITLE">
        <meta itemprop="description" content="This is the page description">
        <meta itemprop="image" content="http://www.example.com/image.jpg">

    </head>
    <body id="body">
        <p>Hello</p>

        <?php



        $buffer = ob_get_contents();
        ob_end_clean();

        $canonical = "https://www.shittysite.com";

        $placeholders = array("%CANONICAL%");
        $substitues = array($canonical);

        $buffer = str_replace($placeholders, $substitues, $buffer);
        echo $buffer;
        ?>
    </body>
</html>
Cœur
  • 37,241
  • 25
  • 195
  • 267
ii iml0sto1
  • 1,654
  • 19
  • 37

1 Answers1

0

Since no one answered i will do it myself.

Some hosting providers/servers apparently does not have output buffering enabled as default.

I had to allow output buffering in my .htaccess file which i managed to do so with the below code.

php_value output_buffering On
php_value output_handler mb_output_handler

The code is for Apache servers, i hope this helps out some of you out there :)

ii iml0sto1
  • 1,654
  • 19
  • 37