www.webdeveloper.com
Results 1 to 4 of 4

Thread: .htacess redirect based on referrer

Hybrid View

  1. #1
    Join Date
    Sep 2006
    Location
    Ipswich
    Posts
    85

    .htacess redirect based on referrer

    Hi,

    Does anyone know how I would modify the htacess file below so that the first time someone hits this site (i.e. they are visiting from outside the site), they will be directed to default.php (to display a splash page) instead of index.php (whitch typically displays the wordrpress site), and then when they click on a link to index.php (from within default.php), or click on any link from within the site they will not be redirected to default.php, but instead index.php and will be able to navigate the wordpress blog within the site?

    Code:
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

  2. #2
    Join Date
    Dec 2005
    Posts
    2,984
    May I ask why you are reposting this thread? (http://www.webdeveloper.com/forum/sh...d.php?t=256539)

    You can do this with PHP sessions and about 7 lines of code. Modifying .htaccess is not the best approach to solving this problem.
    I've switched careers...
    I'm NO LONGER a scientist,
    but now a web developer...
    awesome.

  3. #3
    Join Date
    Sep 2006
    Location
    Ipswich
    Posts
    85
    This thread is more specifically to do with .htacess rather than wordpress. I think I need to evaluate both types of solution as the site I am developing is not a typical wordpress site, this is a one page wordpress site which places pages as posts on a single page and then has a scroll effect to simulate navigating from one page to another. As the site only has one page I am not sure the suggestion you made on the other thread would be applicable, especially as you said it might cause another problem.

  4. #4
    Join Date
    Dec 2005
    Posts
    2,984
    .htaccess cannot do what you want.

    Here is your code:
    (theme header file)
    PHP Code:
     <?php

     session_start
    ();

     if(!isset(
    $_SESSION['shownsplash'])) {
       
    $_SESSION['shownsplash'] = true;

       
    //store the link that the visitor was coming to in another session variable
       
    $_SESSION['incomingLink'] = $_SERVER['REQUEST_URI'];
       
       
    //redirect to your splash page
       
    header('Location: http://example.com/splash');
       exit;
     }


     
    //rest of your header file here
    ?>
    In your splash page:
    PHP Code:
    <?php
      session_start
    ();

      if(isset(
    $_SESSION['incomingLink'])) {
       
    $link $_SESSION['incomingLink'];
      } else {
       
    //your wordpress root
       
    $link 'http://example.com/blog';
      }

      
    //reset of your splash page here
    ?>

    <!-- your 'continue to site link' which will bring your visitors to wherever they meant to go -->
    <a href="<?php echo $link?>">Continue to Site</a>
    I'm not sure how the rest of the people on this forum feel, but I'm not a huge fan of people asking for solutions without being to put in even the time to think about the logic, let alone the time to come up with some sample code.
    I've switched careers...
    I'm NO LONGER a scientist,
    but now a web developer...
    awesome.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles