aebstract Posted March 10, 2009 Share Posted March 10, 2009 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 :/ Quote Link to comment https://forums.phpfreaks.com/topic/148753-solved-split-two-sites-with-splash-one-time/ Share on other sites More sharing options...
rhodesa Posted March 10, 2009 Share Posted March 10, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/148753-solved-split-two-sites-with-splash-one-time/#findComment-781073 Share on other sites More sharing options...
aebstract Posted March 10, 2009 Author Share Posted March 10, 2009 Yeah .htaccess goes in that other forum, but I figured there would be a solution to be gotten here. Was just showing how I was attempting it so far. Is there an easy way to kill a cookie or session when browser is closed? Quote Link to comment https://forums.phpfreaks.com/topic/148753-solved-split-two-sites-with-splash-one-time/#findComment-781080 Share on other sites More sharing options...
rhodesa Posted March 10, 2009 Share Posted March 10, 2009 PHP Sessions and cookies with a lifetime of 0 will automatically close when the browser is closed Quote Link to comment https://forums.phpfreaks.com/topic/148753-solved-split-two-sites-with-splash-one-time/#findComment-781083 Share on other sites More sharing options...
aebstract Posted March 10, 2009 Author Share Posted March 10, 2009 thanks Quote Link to comment https://forums.phpfreaks.com/topic/148753-solved-split-two-sites-with-splash-one-time/#findComment-781086 Share on other sites More sharing options...
aebstract Posted March 10, 2009 Author Share Posted March 10, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/148753-solved-split-two-sites-with-splash-one-time/#findComment-781160 Share on other sites More sharing options...
premiso Posted March 10, 2009 Share Posted March 10, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/148753-solved-split-two-sites-with-splash-one-time/#findComment-781168 Share on other sites More sharing options...
rhodesa Posted March 10, 2009 Share Posted March 10, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/148753-solved-split-two-sites-with-splash-one-time/#findComment-781174 Share on other sites More sharing options...
aebstract Posted March 10, 2009 Author Share Posted March 10, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/148753-solved-split-two-sites-with-splash-one-time/#findComment-781259 Share on other sites More sharing options...
rhodesa Posted March 10, 2009 Share Posted March 10, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/148753-solved-split-two-sites-with-splash-one-time/#findComment-781269 Share on other sites More sharing options...
aebstract Posted March 10, 2009 Author Share Posted March 10, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/148753-solved-split-two-sites-with-splash-one-time/#findComment-781319 Share on other sites More sharing options...
rhodesa Posted March 10, 2009 Share Posted March 10, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/148753-solved-split-two-sites-with-splash-one-time/#findComment-781327 Share on other sites More sharing options...
aebstract Posted March 10, 2009 Author Share Posted March 10, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/148753-solved-split-two-sites-with-splash-one-time/#findComment-781335 Share on other sites More sharing options...
rhodesa Posted March 10, 2009 Share Posted March 10, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/148753-solved-split-two-sites-with-splash-one-time/#findComment-781363 Share on other sites More sharing options...
aebstract Posted March 10, 2009 Author Share Posted March 10, 2009 That's what I was going to do originally, but many places in the website link to the root directory to go back home so it wouldn't work out. =[ Quote Link to comment https://forums.phpfreaks.com/topic/148753-solved-split-two-sites-with-splash-one-time/#findComment-781373 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.