Jump to content

Recommended Posts

Not sure this is the right place, though I had this in the Apache HTTP Server section since yesterday and no hits on it. If this is the wrong place just delete it or something :/ Though, maybe theres something I can do with php :)

 

Here is my .htaccess:

Code:

DirectoryIndex /splash/index.html /splash/index.php index.pl index.php index.html
RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([[:alnum:]_]+)/$ /index.php?page=$1 [NC,L]
RewriteRule ^([[:alnum:]_]+)/([[:alnum:]]+)/$ /index.php?page=$1&var1=$2 [NC,L]
RewriteRule ^([[:alnum:]_]+)/([[:alnum:]]+)/([[:alnum:]]+)/$ /index.php?page=$1&var1=$2&var2=$3 [NC,L]
RewriteRule ^([[:alnum:]_]+)/([[:alnum:]]+)/([[:alnum:]]+)/([[:alnum:]]+)/$ /index.php?page=$1&var1=$2&var2=$3&var3=$4 [NC,L]
RewriteRule ^([[:alnum:]_]+)/([[:alnum:]]+)/([[:alnum:]]+)/([[:alnum:]]+)/([[:alnum:]]+)/$ /index.php?page=$1&var1=$2&var2=$3&var3=$4&var4=$5  [NC,L]

 

 

The only thing important at this point is the top line: DirectoryIndex /splash/index.html /splash/index.php index.pl index.php index.html

 

I have two main websites running out of one domain. domain.net and domain.net/directory

I am needing to have it so that when you go to domain.net you get the splash screen the first time (which is why I added the /splash/index.html) but then need to be able to get out of that splash directory to the actual website. If I change my links to domain.net/index.php or domain.net/directory/index.php I don't run in to a problem. Though, I have some links throughout the websites that will reference just the main directory and not the individual .php file, so that begins to be an issue that someone may click a link and get sent to the splash screen, rather than that sites home page :/

yes...this should be in the Apache section

 

DirectoryIndex doesn't work like that. It takes a list of filenames (not paths) to check for when just the folder is provided. With what you are looking to do, you will need to use either:

-a server-side language + a cookie or session

-JavaScript + a cookie

 

When the user visits the page, check the session or cookie, if it doesn't exist redirect them to the splash page. Then, have the splash page set the session or cookie

Okay I have this now:

 

  ini_set('session.cookie_lifetime', 0);
    session_start();

    if (isset($_GET["set"])){
    $_SESSION['site_choice'] = $_GET["set"];
    header("Location: http://www.berryequipment.net/");
    exit;
    }

 

Then I direct the user to the correct page depending on what the session is set to. Am I using the lifetime part incorrectly? I closed the browser, waited a few moments and reopened, went to the website and was being redirected immediately as the session was still set.

Just so we are clear, when you are re-opening the browser. You are not going to http://www.yoursite.com/script.php?set=yes

 

You are just trying to goto http://www.yoursite.com/script.php and it is still redirecting you?

get rid of the ini_set() and you don't need to use $_GET for anything...

 

second...please don't redirect someone to a splash page if they are deep linking (meaning they are linking to a lower level page...not the home page)

 

On each sites index page (should be something like index.php in your root folder), put the following at the top:

<?php
  if(session_start()){
    if(!isset($_SESSION['splash']) || !$_SESSION['splash']){
      //The haven't been to the splash page yet
      header('Location: /splash/index.php');
      exit;
    }
  }
?>

 

then, in your splash:

<?php
  session_start();
  $_SESSION['splash'] = true;
?>

 

that way, if it's their first time to the homepage, it will redirect them to the splash

That's great and all, but it's two completely different sites. Which is why it is split in to two, and "splash" isnt going to be set as 'true' it is being set as either poultry or performance so that I know which site they want to view. Premiso, I close the browser and then go to the domain.net and am directed to whatever was last time chosen. Rhodesa I asked about how I could have it so when you close the browser it kills the session, and you said to set the lifetime to 0, which is why I have the ini?

Rhodesa I asked about how I could have it so when you close the browser it kills the session, and you said to set the lifetime to 0, which is why I have the ini?

i can see how my statement could have been confusing...i meant it like this:

-PHP Sessions will automatically close when the browser is closed

-Cookies with a lifetime of 0 will automatically close when the browser is closed

as far as the lifetime being set for cookies (which we aren't doing anyways) it's an argument you pass when creating the cookie...not an ini setting

 

is it the same splash page for both? just set a session variable for which page they came from before redirecting:

<?php
  if(session_start()){
    if(!isset($_SESSION['splash']) || !$_SESSION['splash']){
      //The haven't been to the splash page yet
      $_SESSION['last_page'] = $_SERVER['REQUEST_URI'];
      header('Location: /splash/index.php');
      exit;
    }
  }
?>

 

then, on the splash page you can use the $_SESSION['last_page'] variable to send them back to where they came from

 

p.s. - my 2 cents on splash pages is they are REALLY annoying and i've been known to leave a site just because they sent me to a splash page

Okay maybe calling it a splash page is almost incorrect, though it is technically a splash page. Like I said it is two COMPLETELY different websites. My boss was against the idea of setting up space and everything and getting another domain, wanted to keep it on the same domain name. One if for poultry processing, dealing with clients like Tyson Foods, Foster Farms, lalala. The other site is for performance racing parts which deals with performance part shops and whatnot. This is the reason for the splash, to separate them and let the user choose where they want to go. The domain berryequipment.net will be what the user goes to regardless of where they want to end up, though if they choose poultry they will be redirected to the actually "berryequipment.net" and performance will be "berryequipment.net/performance". Hopefully this makes more sense now. Anyway, the code I came back and posted does the job fine, it just isn't killing the session when the browser is closed?

ok...the session killing depends on the browser. you will need to close the ENTIRE browser for most...not just the tab.

 

p.s. - where is your hosting. by the sounds of it, you should set up subdomains for each:

berryequipment.net/ <- Splash Page, with options to go to each site
performance.berryequipment.net/
poultry.berryequipment.net/

or put each site in a sub directory:

berryequipment.net/ <- Splash Page, with options to go to each site
berryequipment.net/performance
berryequipment.net/poultry

 

this way you don't have to track anything

I'd like to keep the main site as berryequipment.net though, that's the only problem :/ The hosting is through OLM. The browser I was using was firefox, and I was closing the entire browser. I think as long as it will kill the session in a reasonable amount of time then it will be okay.

ok...one other option...move the splash page to the root directory:

berryequipment.net/splash.html index.html

set the directory index via htaccess for the root directory as the splash page:

DirectoryIndex splash.html

then, on the splash page, have it point to full url:

berryequipment.net/performance/index.html
berryequipment.net/index.html

then, if they go to berryequipment.net/ it will show the splash page, but if you go to berryequipment.net/index.html it will go right to this site. no php, no sessions, no cookies

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.