Forum Moderators: coopster
Now, I'm no expert in this area, so I need your guys help.. How can I use php to give each of the pages its own title?
So far I've only made pages in php / html that uses the same title as the index.php does, and this isn't exactly the best SEO i know of ;)
I would like the page to show only:
(examples)
www.mydomain.com/widgets.htm
with the title:
Widgets here, widgets there, widgets everywhere
and then
www.mydomain.com/widgets2.htm
with this title:
Cool widgets, nice widgets, fun widgets
when the urls would really be:
www.mydomain.com/index.php?site=widgets
and
www.mydomain.com/index.php?site=widgets2
Is this possible when I use a index.php looking something like this: (short version)
if(!QUERY_STRING) {
include "temp/top.tmp";
include "temp/main.tmp";
include "tmp/bot.tmp";
}
Oh.. and also, when converting query_strings from
www.mydomain.com/index.php?page=red
to
www.mydomain.com/red.htm,
so that users will see
www.mydomain.com/red.htm
- what will google see?
I'm terrible sorry for this long post, and the tons of questions, but I would be more than grateful for some guidelines on how to do this :)
takes a bit to answer when there are lots of questions.
for the part about changing the url that appears to the user you will need to look into using mod_rewrite. We have a primer available from the apache forum
Mod_Rewrite Beginning [webmasterworld.com]
there are also a couple of other threads in the Apache forum library [webmasterworld.com]
>> - what will google see?
google sees the same thing as users see, your rewritten url
as far as the templating goes there are a couple ways of doing it. Using the query string, as in your example, is very possible. You would probably use $_SERVER['HTTP_REFERER'] and then have to pull the keywords out of that. From there you could do your title accordingly.
I am not the biggest fan of this method, even though I have employed it. You are better off haveing a title targetted to the content of each specific page.
This looks like it would be a database driven site, if that is the case then you can have an extra column in your database that stores your title for the page and pull that along with the content.
If it isn't db driven and you actually have content in each file which goes through a template then you just add another var in your template and set it in each file before the template is called.
The only thing that concerns me if I use a DB: Wouldn't I also want to (have to?) write a kind of a admin page where I easily can add the content to each different page.. Like the title, articles, outgoing links for that special page and so on..?
Or would I be better of doing this just using phpMyAdmin or MySqlfront. I am a noob when it comes to setting up db's, and using my head to put it up the way I would benefit from when I develop the page; Like what kind of fields I should put in what kind of different tables..
But anyways.. Thank you for some great answers, now I'll go and try to study some DB examples ;)
you don't need to rush out and switch to db, I was just looking at the query string examples and assumed. Another thread that might help from the PHP library [webmasterworld.com]
A dynamic site in 2 minutes [webmasterworld.com]
that might give you some ideas.
and also, with all the sites I have done I have never used db driven content through a template, I don't like it.