I want the title page to be changed so that a crawler can see it.
The URL is of the format: public.sample.com/account/Disney
I load a standard, global header include file using require()
That's where the current default tags are defined.
IF the URL is public.sample.com/account/Disney, I would like the tag to read, instead:
This is an account profile for Disney
I believe something would need to be written in this global header file, but not sure what.
Thanks.
Super simple example to get you started.
<title><?php
if ( preg_match('/([^\/]+)\/([^\/]+)$/', $_SERVER['PHP_SELF'], $matches) ) {
list($dummy, $profileType, $profileName) = $matches;
$safeProfileType = htmlentities($profileType);
$safeProfileName = htmlentities ($profileName);
echo "This is an $safeProfileType profile for $safeProfileName";
} else {
echo "Unknown profile!";
}
?></title>
Edited per Allain Lalonde comment. (Hope this is what he meant)
im not sure exactly what you are looking for here, but to have a dynamic title you can do:
<title><?php echo $theDynamicTitle; ?></title>
来源:https://stackoverflow.com/questions/441565/how-can-i-change-the-title-tag-dynamically-in-php-based-on-the-url-values