Jump to content

include() and url


bthompson00

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.