bthompson00 Posted April 23, 2009 Share Posted April 23, 2009 Hi, this should be fairly straight forward... My site works with the include() function. For example, www.mysite.com/main.php#aboutUs This opens the main.php file and includes aboutUs.php in the content section of main.php. This all works fine. What id like however, is if a user directly navigates to aboutUs.php, they are redirected to main.php#aboutUs. The problem is if I include url detection script in aboutUs.php, that $_SERVER['REQUEST_URI'] returns aboutUs.php - no matter whether we're on aboutUs.php or main.php. Make sense? Any ideas? Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/155292-include-and-url/ Share on other sites More sharing options...
ballhogjoni Posted April 23, 2009 Share Posted April 23, 2009 why would you want to do that? its better for SEO to have more than one page. Quote Link to comment https://forums.phpfreaks.com/topic/155292-include-and-url/#findComment-817011 Share on other sites More sharing options...
bthompson00 Posted April 23, 2009 Author Share Posted April 23, 2009 I know its better to have more than one page, but dynamically changing page content based on a named anchor SIGNIFICANTLY speeds up page load times. Also, I couldn't find evidence to link named anchors being poor with regards to SEO. Anyway, that debate aside, any ideas for my problem? Quote Link to comment https://forums.phpfreaks.com/topic/155292-include-and-url/#findComment-817016 Share on other sites More sharing options...
ballhogjoni Posted April 23, 2009 Share Posted April 23, 2009 its faster to cache your pages, but not to dynamically switch between pages. If you are talking about just changing some content on the page and not load the entire page again, then you want to look at ajax. Quote Link to comment https://forums.phpfreaks.com/topic/155292-include-and-url/#findComment-817018 Share on other sites More sharing options...
bthompson00 Posted April 23, 2009 Author Share Posted April 23, 2009 Thanks, I am using Ajax to achieve this. Debate aside, do you have any suggestions for my problem? Quote Link to comment https://forums.phpfreaks.com/topic/155292-include-and-url/#findComment-817020 Share on other sites More sharing options...
bthompson00 Posted April 23, 2009 Author Share Posted April 23, 2009 main.php: include("aboutUs.php"); aboutUs.php: require("url.php"); url.php: if (substr($_SERVER['HTTP_REFERER'], -!="main.php") { if (substr($_SERVER['REQUEST_URI'], 1)=="aboutUs.php") { header('Location: http://www.mysite.com/main.php#aboutUs'); } elseif (//etc) { //etc; } else { header('Location: http://www.mysite.com/main.php'); } } Quote Link to comment https://forums.phpfreaks.com/topic/155292-include-and-url/#findComment-817042 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.