Gossamer Forum
Home : Products : Gossamer Links : PHP Front End :

why add 'do=page' to links?

Quote Reply
why add 'do=page' to links?
Since page.php defaults to $do = "page" if not specified in the query string, it seems the URLs could be made more concise by not bothering to pass through 'do=page'.

Any reasons why it would need to be there?

Also, I haven't found any mention of what $url_hidden accomplishes. Is that for passing through session info if not done with cookies?

Dan

Last edited by:

Dan Kaplan: Jun 27, 2002, 11:46 AM
Quote Reply
Re: [Dan Kaplan] why add 'do=page' to links? In reply to
In Reply To:
Since page.php defaults to $do = "page" if not specified in the query string, it seems the URLs could be made more concise by not bothering to pass through 'do=page'.

Yes, you could, but I like to be consistent.

In Reply To:
Also, I haven't found any mention of what $url_hidden accomplishes. Is that for passing through session info if not done with cookies?

Session info, and for templates (t=templatename), as well as anything required in the future.

Adrian
Quote Reply
Re: [brewt] why add 'do=page' to links? In reply to
Quote:
Yes, you could, but I like to be consistent.
Gotcha. Can that be made a config option for down the road? One of the major complaints I hear about dynamic pages/sites is the length of the resulting URLs. Seems any chance to shorten the URL without adversely affecting the script should be taken...

Along the same lines, is $cat_id used anywhere other than selecting categories to browse? I would rather use $cat (shorter and easier to type -- some people actually do type in URLs manually and don't care for underscores) if possible, assigning the $cat value to $cat_id for internal processing in page.php. I just don't want to break something else unforseen in the process. :)

Quote:
Session info, and for templates (t=templatename), as well as anything required in the future.
That makes sense, thanks.

Dan
Quote Reply
Re: [Dan Kaplan] why add 'do=page' to links? In reply to
To follow up on this, to remove the frivolous 'do=page' query string items, you need to edit the hard coded values in line 130 of Utils.inc.php. The same would have to be done to go to a more aesthetically pleasing 'cat' instead of 'cat_id'...

Something else that I think could be improved for flexibility is to not hard code page.php everywhere. I'm sure a lot of people will want to run it as their home page (or the default index in a subdirectory). With the current setup, that requires changing page.php to index.php throughout, when it could easily be accomplished by a setup variable. All that would then be required is to rename page.php to index.php by the user.

Dan
Quote Reply
Re: [Dan Kaplan] why add 'do=page' to links? In reply to
In Reply To:
Something else that I think could be improved for flexibility is to not hard code page.php everywhere.
I've updated my local copy so that the script name is set in page.php ($php_self), and the templates have been updated to use <?echo $php_self?> instead of just page.php. I'd like to make it automatic, but it's kind of a pain to $HTTP_SERVER_VARs['PHP_SELF'] isn't just the script name itself, and may have extra stuff after the filename.

Adrian
Quote Reply
Re: [brewt] why add 'do=page' to links? In reply to
Thanks, that should be nicer to work with.

I haven't tested it, but I thought $PHP_SELF would be undefined with register_globals turned off? That would probably still work as a directory index (i.e. if changed from page.php to index.php)... Is that not right?

Dan
Quote Reply
Re: [Dan Kaplan] why add 'do=page' to links? In reply to
In Reply To:
I haven't tested it, but I thought $PHP_SELF would be undefined with register_globals turned off?
? $php_self != $PHP_SELF. $HTTP_SERVER_VARS['PHP_SELF'] isn't just 'page.php', it's the path to page.php as well as any paths after it. For example, if page.php is in /stuff/, and someone accessed it through:
/stuff/page.php/Some_Category/Some_Link
then ALL of that will be in $HTTP_SERVER_VARS['PHP_SELF'], not just page.php. There's no reliable way to parse that out because you someone could also do:
/my.php/page.php/evil.php
assuming they installed it into my.php directory...

Adrian
Quote Reply
Re: [Dan Kaplan] why add 'do=page' to links? In reply to
This might help you find just the script name:

$url_data = explode("/",$PHP_SELF);
$script_name = $url_data[count($url_data)-1];
Quote Reply
Re: [edernest] why add 'do=page' to links? In reply to
Wow, a post to the PHP forum! :)

I never responded to Adrian's last post because, well, I couldn't figure out what the heck he was talking about... If someone entered /stuff/page.php/Some_Category/Some_Link , why would you care about the garbage at the end? Sounds like an invalid page request to me...

Dan
Quote Reply
Re: [Dan Kaplan] why add 'do=page' to links? In reply to
It's not clear to me what he is talking about either. I thought you were looking for a way to extract the script name from $PHP_SELF. Under most circumstances, the full path to the script is desired anyway.
Quote Reply
Re: [edernest] why add 'do=page' to links? In reply to
I wasn't really worried about extracting the script name. I figure it will be set once on initial install, and probably never touched again. As such, it makes more sense to me to have it be a config variable instead of something that's calculated on every page request.

Dan
Quote Reply
Re: [Dan Kaplan] why add 'do=page' to links? In reply to
It's actually a valid page request. /stuff/page.php/Some_Category/Some_Link would call page.php and then (depending on your webserver) store /Some_Category/Some_Link in the PATH_INFO environment variable.

Adrian
Quote Reply
Re: [brewt] why add 'do=page' to links? In reply to
What would PATH_INFO get used for in that case?

Dan
Quote Reply
Re: [Dan Kaplan] why add 'do=page' to links? In reply to
In Links we use it as another way to specify the category. For example, you can do this: http://run-down.com/.../Clubs/US%20-%20West

Adrian
Quote Reply
Re: [brewt] why add 'do=page' to links? In reply to
Aha!!! That's very good to know. One of the things that has troubled me (as discussed in a Links SQL Discussion thread) is how to redirect requests for the old static directory pages to the new dynamic ones, if switching to a dynamic system.

Of course, any requests for the static directory pages would probably also contain the index/more file name (I never liked that that was built into the links by default, for this very reason), and it appears adding the old file name onto PATH_INFO does not work. I see potential there, but it could require some creative Apache regex'ing...

Dan
Quote Reply
Re: [brewt] why add 'do=page' to links? In reply to
I've read through this thread several times now in a search for inspiration on how I might generate some mod_rewrite rules in order to make a PHP links front-end appear to have static urls. It sounds like it's possible, but I'm not sure I understand what actually needs to be changed in the script configurations (and where) to make it generate urls like:

http://www.example.com/....php/Category/Subcat

instead of:

http://www.example.com/...ge&cat_id=127398

Do I need to edit the Utils.php.inc file? If not - where should I look? Sorry if I'm being dense, it just looks like you guys came to some kind of useful conclusion in this thread, but I can't quite figure out what it is!

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] why add 'do=page' to links? In reply to
You don't need to change anything for that to work. I believe we added that functionality in 2.1.

Adrian
Quote Reply
Re: [brewt] why add 'do=page' to links? In reply to
Hmm. Maybe I'm confused. My default_php templates are definitely not generating urls like that. They are generating category links like:

http://www.example.com/...age&cat_id=XXXXX

Do I need to change something in the templates so that those appear in the other format?

Thanks for your help.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] why add 'do=page' to links? In reply to
It doesn't generate url's like that, but it can accept url's in the other format.

Adrian
Quote Reply
Re: [hennagaijin] why add 'do=page' to links? In reply to
Be aware that doing so can get put you in the dog house of your shared hosting provider. Making dynamic pages appear static can be hell on servers when indexed by high speed spiders, so any host worth hosting with will frown heavily on the activity.

Dan
Quote Reply
Re: [Dan Kaplan] why add 'do=page' to links? In reply to
My host may not be worth hosting with (they've been great historically, though a little problematic lately), but I nonetheless have a whole bunch of dynamic content being accessed via static-looking urls and mod_rewrite and I haven't encountered major problems. Most major spiders are fairly gentle, but you're right that there are some that are less polite (once you catch them, however, you can usually ban them altogether with robots.txt).

I'm using GT's Search Engine Friendly forum templates, along with my own simplified implementation for numerous DBManSQL databases. As for LinksSQL, I currently accomplish my url needs with:

RewriteRule ^links/(.+) /cgi-bin/page.cgi?g=$1 [L]
RewriteRule ^links/?$ /cgi-bin/page.cgi [L]


That said, I've been looking at making the switch to PHP so that I can use mysql_pconnect to reduce the number of MySQL connections (you may have noticed a number of posts I've made on this subject lately.) I'm not interesting in making that switch, however, unless I can still have search-engine-friendly (i.e. static-looking) urls in my links directory.

So... I feel like a major dunce for continuing to ask the same question, but I have to admit that I'm still not clear on how to get a php template to generate those static-looking urls. I didn't want to badger Adrian any longer, but since I've got your attention, maybe you can shed some light on this. What do I need to change so that category and detailed links appear in that static-like format in my php templates? Does a change need to be made to the templates themselves, or to an admin setting, or is there a global I need to write?? I know it must be something obvious, but its apparently SO obvious that I'm missing it entirely! wouldn't be the first time... Unsure

Many thanks for any assistance you can provide.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] why add 'do=page' to links? In reply to
In Reply To:
there are some that are less polite (once you catch them, however, you can usually ban them altogether with robots.txt).
Well, many of them are offline web browsers which are challenging, if even possible, to ban without also banning legitimate visitors.

In Reply To:
I'm not interesting in making that switch, however, unless I can still have search-engine-friendly (i.e. static-looking) urls in my links directory.
I'm amazed that for how many times this has been brought up, I've yet to see any conclusive evidence that dynamic URLs are not search engine friendly...

In Reply To:
but since I've got your attention...
Barely. :) I just moved and am slowly climbing out of the box I've been living in for the past week, so attending to other people's projects is a distant second priority to my own web stuff that needs my attention, and that is barely getting done next to moving/cleaning/unpacking/painting/renovating type projects...

In Reply To:
What do I need to change so that category and detailed links appear in that static-like format
Short answer: you don't. As Adrian alluded to, that is simply a way of accessing the dynamic categories, not a built-in linking method (which makes the feature pretty much frivolous, if not worthless, in my opinion).

I would't even want to begin looking into how to change that. It would require overhauling the category functions that build all cat/subcat links (never an easy thing) and probably performing a reverse lookup to get the category name in place of its corresponding ID.

Before you venture down that road, I would consider whether the goal is even a truly static-looking URL to search engines (brushing aside the topic of whether or not it even matters). My guess is it is not.

Dan
Quote Reply
Re: [Dan Kaplan] why add 'do=page' to links? In reply to
I think I'll just stick with my cgi setup, then. I managed to cut down on my number of connections considerably by eliminating jump.cgi in favor of direct links to the url in question (I didn't really have any need to track hits).

As for the other, increasingly OT stuff...

Translate "search engine" as "Google". That's really 90% of what I'm interested in when it comes to search engine marketing. The other 10% is the DMOZ ODP, which obviously doesn't use spiders at all.

And your suspisions are somewhat correct - Google does index dynamic urls. While no one outside of the Googleplex knows their exact algorythm, anecdotal evidence suggests that there is some kind of threshold relating to the number of parameters (or perhaps even total length), above which Googlebot will not trek. That, of course, could change at any time. But for now - that's how they do it. Regardless, "static" content makes great spider food, so if there's a way to feed Googlebot urls free of question marks and ampersands, I'm going to do it. I do have some concerns about the heavy mod_rewrite burden on Apache, but I guess that can be addressed if/when it becomes a problem.

Thanks for the advice, and good luck recovering from your move.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund