Deprecated: Function create_function() is deprecated in /home2/blogwebhostingbu/public_html/wp-content/plugins/facebook-like-box-responsive/facebook-like-box.php on line 29
Skeleton directory part 2: PHP for dynamic content in new account default home page - WebHostingBuzz US Blog
Deprecated: Function create_function() is deprecated in /home2/blogwebhostingbu/public_html/wp-content/plugins/codecolorer/lib/geshi.php on line 4698

Notice: Undefined variable: defaults in /home2/blogwebhostingbu/public_html/wp-content/plugins/fatpanda-facebook-comments/plugin.php on line 366
 

Skeleton directory part 2: PHP for dynamic content in new account default home page

Posted on 21 Jan 2011 by Alan Burns

This is a continuation from Skeleton directory part 1.

In my skeleton directory I placed a /public_html directory containing an index.php file. This ensures that a client’s brand new domain, or in fact any new cPanel account I create, immediately has a home page viewable by whoever seeks that domain in their web browser. I include a little PHP in the web page code, to customize the message to the particular domain.

My index.php file includes:

  • Information on my hosting, and code to automatically display the new domain name with a message.
  • Meta link to load my own central CSS file, hosted centrally, to provide design and formatting for the page consistent with that of own my web site.
  • IMG reference to display the GIF of my company logo, which is hosted centrally.

To dynamically display the domain name used to reach the web page, the HTML BODY of my index.php file contains this PHP code:

<h1>< ?
$host = $_SERVER['SERVER_NAME'];
$host_domain = str_replace("www.", "", $host);
echo $host_domain;
?></h1>
<div>
<p>< ?
$host = $_SERVER['SERVER_NAME'];
$host_domain = str_replace("www.", "", $host);
echo $host_domain;
?> has not set up their web site yet.</p></div>

When served by the web server, that page will display the new domain name in large H1 heading type, and further down would say, for example: “bigfalafel.com has not set up their web site yet.”

To add a professional touch, I also use the following PHP code in the HTML HEAD:

<head>
<title>< ?
$host = $_SERVER['SERVER_NAME'];
$host_domain = str_replace("www.", "", $host);
echo $host_domain;
?> </title></head>

That code dynamically displays the new domain name in the title bar of the browser. The bit about str_replace(“www.” strips away the “www.” if a visitor prepended that to the domain name when navigating to the site. Personally, I prefer the look of a domain name without the overused “www.”, but of course you could remove that string if you don’t agree.

PHP is a powerful web language. With a little imagination and some skill, one could go far beyond what I have done to display all manner of dynamic content. The beauty of cPanel/WHM’s skeleton directory is that you set it up once, and it applies to every new cPanel account that you create.

WebHostingBuzz Logo

© WebHostingBuzz USA LLC 2002 - 2024
WebHostingBuzz is a Registered Trademark.
All Rights Reserved.
WebHostingBuzz USA LLC, 850 Southbridge Street, Auburn, MA 01501, USA

1 (800) 252-1887

Payment Logos
  • Webmoney Verified
  • Webmoney Accepted

Sign up for our Newsletter

Scroll to Top