views:

758

answers:

2

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.

A: 

im not sure exactly what you are looking for here, but to have a dynamic title you can do:

<title><?php echo $theDynamicTitle; ?></title>
John Boker
+5  A: 

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)

Beau Simensen
Some care must be taken when doing this since it's possible to craft a URL that could be used for Cross Site Scripting. $profileName should be escaped before it's displayed.
Allain Lalonde
Added htmlentities for the two pieces of data that came from the URL.
Beau Simensen