'parametered' links

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

'parametered' links

Post by Ree »

for me (as i'm a beginner :)) the index.php?page=stuff&id=1&no=2 kind of linking is really nice, understandable and easy to use. but how does it look like for search engines? maybe that kind of linking should be avoided or is it absolutely fine? just something i would like to know.
Last edited by Ree on Sat Jul 16, 2005 11:56 am, edited 1 time in total.
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post by bokehman »

Many search engines don't check links with query strings as these should only be used for dynamic content. (why would a search engine want to list dynamic content). Looking at my log file though it would seem that the google bots do open these links.

I can't think of any good reason for using a query string for a static page (but your mileage may differ).
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

Many script engines will cache any URL they can reach, includeing dynamic ones not behind a form interface. This is good, typically, as you want to cache the pages produced by things like http://domain/index.php?page=home
which is rather common idiom for some php coders.

If you're afraid of them cacheing you pages, there are no-cache headers, robots.txt, etc

If you want them to cache your pages, you can look into the various url shortening techniques to masquerade the variables as directories.
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post by bokehman »

This: http://domain/index.php?page=home is unnecessary and just bad design. And 9 times out of 10 just leads to header('Location: ... ');. Why isn't a standard url being used for this static page?
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

bokehman wrote:This: http://domain/index.php?page=home is unnecessary and just bad design. And 9 times out of 10 just leads to header('Location: ... ');. Why isn't a standard url being used for this static page?
Personally I agree that its bad design. But there are reasons for it, especially some cases where the develop doesn't have sufficient control over the hosting environment. However it is EXTREMELY common in novice PHP sites... Many tutorials strongly advocate it too, sadly. Some going so far as to claim its a good "Controller" in an MVC design....

However in most cases I've seen its not followed by a header, but by an include("{$page}.php") (Hopefully after some security checks!!!)
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post by bokehman »

I do the opposite. The only page that is included is the template which is used throughout the site. The template page includes functions and these are called as required. Something like this:

їphp]
$description ='';
$keywords ='';
$stylesheet ='';
$title ='';
$javascript'';

require_once('../templates/template.php');

//Get top of the page
top_of_page($description, $keywords, $stylesheet, $title, $javascript);

//Get navigation menu
nav_menu_1();

//Changeable content here

//Get bottom of the page
bottom_of_page();
ї/php]

Anyway I think I'm getting sidetracked here.
Last edited by bokehman on Sat Jul 16, 2005 11:55 am, edited 2 times in total.
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Post by Ree »

i'm now coding a little admin interface (for learning purposes), and i do have that kind of links - eg, i have //index.php?page=(add_news, view_news, add_prod, add_serv, ...). after your input on the same, i do see now that this kind of linking is not actually neccessary for me because the only thing that little switch_page() function i have does is include a page in content <div> according to the page value passed, so i can very much do without it just by copying the layout and including files myself since i have a fixed amount of pages. just i wonder then - why is this kind of linking quite common on the net and in tutorials (i'm talking about the simpliest navigation - just like my example)? even zend.com has a tutorial on that!

now regarding links while working with database items (dynamic stuff), then i think that kind of linking is acceptable - for me it works just great.
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post by bokehman »

Ree wrote:why is this kind of linking quite common on the net and in tutorials
I don't know! The purpose of the query string is to send data gathered from the client, to the server for processing there. Using it in links sent from the server to the client is ridiculous.

A valid use might be something like this: Look how quick the DNS responds at this website!. But for dishing up static pages it is plain wrong.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Even if you have dynamic pages, search engines will crawl them if you link to them.. like for example view=females&sort=age will be crawled if you have that linked.

However it won't be crawled if it's behind things such as a login, or secure connections.
Post Reply