Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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