Vocademy |
This is a problem that was probably unique to my website. However, this can give you insight into troubleshooting similar problems.
Clicking certain links loads a navigation page then loads the page specified in the link. This means that script errors can interfere with loading the page. Such errors were resulting in 404, page not found errors. However, copying the link and pasting it into the address bar of a web browser caused a normal page load. This links included several GET variables, such as:
http://site.com/page.php?page=20&directory=thisdirectory
No problem there. However, clicking the link ultimately created a new URL which added more GET variables. One of these variables came from the following environment variable (referrer is misspelled because that misspelling got etched in stone many years ago).
$_SERVER['HTTP_REFERER']
That variable is passed to the new page so it can be determined if the visitor clicked a link on the same website or some other website.
Unfortunately, that variable sometimes contained more GET variables, such as:
http://site.com/otherpage.php?page=12&directory=thatdirectory
Therefore the final link looked like this:
http://site.com/page.php?page=20&directory=thisdirectory&referer=http://site.com/otherpage.php?page=12&directory=thatdirectory
Do you see the problem? There are now two lists of GET variables, the second starting at the second question mark. Can you guess which list was passed to the next page? That's right, the list after the second question mark. Once discovered, the solution is simple. The referring page was only needed so the ultimate page could see that the referring page was on the same site. Therefore, the variables in the referrer variable were unneeded. All I had to do was truncate the list of GET variables from the referrer as follows:
$referer = $_SERVER['HTTP_REFERER'];
$referer = substr($referer, 0,
strpos($referer, "?"));
The second line truncates the $referer variable starting with the question mark (that is the only question mark in the link at this point). It works by essentially saying that the $referer variable is now only the $referer variable from the beginning to the last character before the question mark. Then, when it is appended to the original link, it doesn't have the second list of GET variables.
Vocademy |