On a recent job, the client consistently demanded a splash page for their website. Despite my consistent groans and insistence that the implementation of a splash page on their website would instantly turn it, them and me to the dark side, I gave in.
I reluctantly implemented a quick solution using WordPress. I used php to check if the user was referred to the index page from within the site or from out with the site.
Usually splash pages use an “index.html” page in the website root with a link to a directory such as “blog“. But I had installed WordPress in the root. I could not be bothered moving the installation folder from the root to another folder to suit the splash page nonsense. So I used php with an if statement to check if the user was referred to the site from outside the domain or within and thus display content accordingly:
<?php if( (strpos($_SERVER['HTTP_REFERER'], get_bloginfo('home')) === false) && !$_SERVER['QUERY_STRING']) : ?> <html> <head> <title>Splash Page</title> </head> <body> <h1><a href="http://www.yourwebsite.com">Enter</a></h1> </body> </html> <?php else : ?> <html> <head> <title>Main Page</title> </head> <body> <h1>Welcome to the main page</h1> <h2>By the way Alan is a total ledge!</h2> </body> </html>
In reference to the above code; all that is before the else statement i.e. the following code:
<html> <head> <title>Splash Page</title> </head> <body> <h1><a href="http://www.yourwebsite.com">Enter</a></h1> </body> </html>
Will be the output splash page. All that is after the else statement i.e. the following code:
<html> <head> <title>Main Page</title> </head> <body> <h1>Welcome to the main page</h1> <h2>By the way Alan is a total ledge!</h2> </body> </html>
Will be output when the user clicks enter on the splash page.