Brenty Posted March 10, 2006 Share Posted March 10, 2006 [b]Intro:[/b]I have a server configuration that assigns folders as subdomains through DNS. When you FTP the files, you use the folder, but when you view them, you use that folder name as a subdomain - Like this:[code]http://www.website.com/subdomain[/code]translates to:[code]http://subdomain.website.com/[/code]You can also access the subdomain folder through the browser like you do with the FTP.Because of this subdomain configuration, a package I'm using is getting a bit confused when reading out php server variables. I've changed the configuration in the software so that it mostly works, however, still have 1 problem, which I've identified to this:[code]if(!isset($_SESSION['ccAdmin'])){ header("Location: ".$GLOBALS['rootRel']."admin/login.php?goto=".currentPage()); exit;// check session path is correct} elseif(strpos(dirname($_SERVER['PHP_SELF']), $_SESSION['AdminPath']) !== 0){ header("Location: ".$GLOBALS['rootRel']."admin/login.php?goto=".currentPage()); exit;[/code]What I believe this code does is create a record of where the user was so that when re-authenticating themself, the software returns to that page. I could be wrong about this (Limited php knowledge), but that isn't the problem anyway.[b]Problem:[/b]From currentPage, I'm getting this result:[code]subdomain/admin/index.php[/code]when I should be getting just...[code]admin/index.php[/code]How can I strip out the subdomain folder from that currentPage result? Quote Link to comment https://forums.phpfreaks.com/topic/4627-truncating-currentpage/ Share on other sites More sharing options...
Brenty Posted March 11, 2006 Author Share Posted March 11, 2006 Anyone?I'm sure this is easy for someone who knows. I'd consider using preg_replace, but don't know enough about php code yet. Quote Link to comment https://forums.phpfreaks.com/topic/4627-truncating-currentpage/#findComment-16409 Share on other sites More sharing options...
txmedic03 Posted March 13, 2006 Share Posted March 13, 2006 [code]$result = "subdomain/admin/page.php";$result = substr($result, strpos($result, '/', 1)+1);echo $result;[/code]You should be able to adjust this to fit your specific needs. I honestly didn't look to see what your variable names are or anything just at your question and wrote this basic solution. Quote Link to comment https://forums.phpfreaks.com/topic/4627-truncating-currentpage/#findComment-16923 Share on other sites More sharing options...
Brenty Posted March 13, 2006 Author Share Posted March 13, 2006 [!--quoteo(post=354439:date=Mar 13 2006, 04:33 AM:name=txmedic03)--][div class=\'quotetop\']QUOTE(txmedic03 @ Mar 13 2006, 04:33 AM) [snapback]354439[/snapback][/div][div class=\'quotemain\'][!--quotec--][code]$result = "subdomain/admin/page.php";$result = substr($result, strpos($result, '/', 1)+1);echo $result;[/code]You should be able to adjust this to fit your specific needs. I honestly didn't look to see what your variable names are or anything just at your question and wrote this basic solution.[/quote]Many many thanks for replying. I was starting to get worried about this.What you've given me has helped send me in the right direction. Although the URL changes (Due to currentPage), it's the folder at the beginning that I need to strip out, and I think your code may just manage it - With adaptions as you said of course.Greatly appreciated, and I'm just off to try it out. I'll post the results later. Quote Link to comment https://forums.phpfreaks.com/topic/4627-truncating-currentpage/#findComment-16930 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.