Using CloudFlare for concrete5

I’ve been using CloudFlare for many of my major high traffic volume concrete5 sites, and I’m getting the significant result now.

Our concrete5 Japan site was reviewed by a major Internet software website, and it caused the high volume traffic yesterday. But it withstood the high traffic volume. Here is the implementation of concrete5 & CloudFlare for both developer and visitors.

CloudFlare DNS & Hosting provider setting

When developing or make the changes of your concrete5 site, you may want to bypass the CloudFlare network .

CloudFlare gives you “direct.EXAMPLE.com” subdomain as your direct access to the root domain.

E.g.
———-
EXAMPLE.COM
———-

CloudFlare suggests you to allocate
———-
direct.EXAMPLE.COM
———-
as your direct access subdomain.

You need to create an “alias domain” that will point to the exactly same directory of your host server.

You could change “direct” to anything else. Make sure you modify all of your CloudFlare, hosting server and the following codes accordingly. (E.g., if you can changing the dev domain to be “access.EXAMPLE.COM”. You want to change every “direct” to “access”.)

/config/site.php

So you want to insert the following code onto /config/site.php

<?php
if (strpos($_SERVER['HTTP_HOST'],'direct') !== FALSE) {
define('REDIRECT_TO_BASE_URL', false); }
?>

* If you’re pasting inside of “<?php ?>” tags remove those tags before inserting.

By default, concrete5 tries to re-direct you to the main domain.
But when you insert the code into site.php, when you access to the site “direct.EXAMPLE.com”, it won’t redirect the domain and keeps you at “direct.EXAMPLE.COM”

/elements/header_required.php (Optional)

This is the optional suggestion. So that Google and other search engine won’t crawl and register your development-only subdomain.

  • Copy: /concrete/elements/header_requied.php
  • To: /elements/header_required.php

Then insert the following code at the bottom of the file

if (strpos($_SERVER['HTTP_HOST'],'direct') !== FALSE) { ?>
<meta name="robots" content="noindex, nofollow">
<?php } else { ?>
<meta name="robots" content="index, follow">
<?php } ?>

* Make sure “<?php ?>” tags are properly wrapped and closed.

Check out CloudFlare powered concrete5 sites!

http://concrete5-japan.org/
http://yokosonews.com/

* as of June 2011

  • Anon

    Thanks…

  • Anon

    Don’t you mean?:
    <?phpif (strpos($_SERVER['HTTP_HOST'],'direct') !== FALSE) {echo '’;} else {echo ”;} ?>
    Cause then it will actually parse…

  • Anon

    I mean…
    if (strpos($_SERVER[‘HTTP_HOST’],’direct’) !== FALSE) {

    • So pretty much, you’re saying the same thing as I wrote.

    • OK now I got it.
      I forgot a opening curly brackets “{“. Thank you!!!

  • I get it clear idea about concrete Application how its working on CloudFare.All the points are explained very clearly. 

  • I get it clear idea about cloud hosting and how it’s working all the points are explained very clearly.Reading this kind of article is worthy.

  • Miroslav Wiesner

    Hi There – I’m trying your “direct” option on my hosted site. I’m confused though should direct.sitename.com be a CNAME Zone Type (like WWW) or an A Zone Type (like ftp, mail, *)

    Thank you!