How do I redirect the users who want to visit my site to a PHP page that has a link to index.php?

When someone go to example.com they should see a PHP page (e.g. a welcome page) where they would find a link to access the front page.

5 Answers 5



You could accomplish this with the Rules module and add granular control over who sees the splash page and when.

Additional Details

Create a new rule. (admin/config/workflow/rules/reaction/add)

React on Event: Drupal is initializing

Condition: Execute Custom PHP Code

$homepage = FALSE;
if (drupal_is_front_page()) {
  $homepage = TRUE;
return $homepage;

Action: Page Redirect

Drupal Rules Exported Rule

This can be copy and pasted into the Rules Import menu. (admin/config/workflow/rules/reaction/import)

{ "rules_show_splash_page" : {
    "LABEL" : "Show Splash Page",
    "PLUGIN" : "reaction rule",
    "TAGS" : [ "splashpage" ],
    "REQUIRES" : [ "php", "rules" ],
    "ON" : [ "init" ],
    "IF" : [
      { "php_eval" : { "code" : "$homepage = FALSE;\r\nif (drupal_is_front_page()) {\r\n  $homepage = TRUE;\r\n}\r\nreturn $homepage;" } }
    "DO" : [ { "redirect" : { "url" : "splash-page-url" } } ]

Tested and working on my dev site.

  • thank you too, i tried your way but it's the same, it's redirect to the splah page everu time visitor go to home page of my site. i just want to redirect once when open the site for the first time Jun 15, 2012 at 7:06

If you're happy to go down the module route, the following should get you started.

You're going to want to set a cookie to see if the user has been to the site before. If the cookie is set, then you know the user has been to your site ebfore and it shouldn't redirect to the splash page.

function MYMODULE_init() {
  if (!isset($_COOKIE['mysite_firstvisit'])) {
    setcookie('mysite_firstvisit', '1');

This project is in alpha, but the Splashify project may be what you're looking for.

  • i can't install this module in my site because it's incompatible with version 7.x-1.0 Jun 15, 2012 at 19:05
  • What version of Drupal are you running?
    – Citricguy
    Jun 16, 2012 at 0:19
  • drupal version 7.14 Jun 17, 2012 at 9:47

I think you're talking about a Splash Screen (or "splash page").

I only know of one module that has such functionality for Drupal 7 (there was the Splash module for Drupal 6 but it hasn't been ported), and that's ThemeKey. One of the features that you can apparently "easily achieve" is:

a front-page / "splash" screen

  • i installed the modules but i did not knwo how to make it, can you put me in the right way? Jun 14, 2012 at 21:06
  • Both of the modules you list link to the Splash project page... the actual link to ThemeKey is here.
    – EmmyS
    Jun 14, 2012 at 21:08
  • Help for ThemeKey (once installed) is at /admin/help/themekey. There's a decent screencast at MustardSeed, although I don't know if it covers splash screens.
    – EmmyS
    Jun 14, 2012 at 21:11
  • @abd See the link from EmmyS
    – Clive
    Jun 14, 2012 at 21:14
  • thank you guys for your help, but what i want exactly is redirect to the splash page just for the first time the visitor ask my site, then it should go back to the original home page when click on the logo of mysite. Jun 15, 2012 at 7:05

I added a page--front.tpl.php in my theme. Drupal picks that up as a splash screen.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.