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! 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. 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? 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. 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? 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'); } } Link to comment https://forums.phpfreaks.com/topic/155292-include-and-url/#findComment-817042 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.