Forum Moderators: coopster

Message Too Old, No Replies

Get Query "?tag=" Vs "/tag/"

How to do "?tag=" as "/tag/"

         

mustdownloads

2:05 pm on Jul 27, 2007 (gmt 0)

10+ Year Member



Can any body guide me

I normally do php GET query for tags by
www.domain.com/?tag=man

but wordpress and technorati use this as
www.domain.com/tag/man

Cna anybody guide me how to do this

bcolflesh

2:18 pm on Jul 27, 2007 (gmt 0)

vincevincevince

4:27 pm on Jul 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can also use the ErrorDocument 404 method.

Set:
ErrorDocument 404 /path/to/phpfile.php

In your .htaccess file

That will direct any request for a URL which doesn't exist to your script.

In your script, read $_SERVER[REQUEST_URI] (typed address in browser), and decide what to do with it.

If you want to give out something, be sure to send, using header(), a 200 OK status to override the default 404 Not Found status.

phparion

6:29 pm on Jul 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



what i am understanding from your question is that you want to know about search enginer friendly URLs Vs queryString (ugly URLs) ...

the wordpress is using apache mod rewrite to follow that URLs scheme but it is not necessary you also implement it with apache mod rewrite. you can find a PURE PHP solution too to implement the same modRewrite kinda URLs scheme. You just need to have a clear-cut logic of fetching URLs and then fetching data from database based on different values.

there is a very good post on doing this with pure php on zend official site but i cannot give you URL because its against the forum URL policy...

StudioKraft

6:31 pm on Jul 27, 2007 (gmt 0)

10+ Year Member



Hello,

The following code is used in OSCommerce for "Search Engine Friendly" pages:


if (strlen(getenv('PATH_INFO')) > 1) {
$GET_array = array();
$PHP_SELF = str_replace(getenv('PATH_INFO'), '', $PHP_SELF);
$vars = explode('/', substr(getenv('PATH_INFO'), 1));
for ($i=0, $n=sizeof($vars); $i<$n; $i++) {
if (strpos($vars[$i], '[]')) {
$GET_array[substr($vars[$i], 0, -2)][] = $vars[$i+1];
} else {
$HTTP_GET_VARS[$vars[$i]] = $vars[$i+1];
}
$i++;
}

if (sizeof($GET_array) > 0) {
while (list($key, $value) = each($GET_array)) {
$HTTP_GET_VARS[$key] = $value;
}
}
}

This takes the URL and converts it into key/value pairs, and then defines $HTTP_GET_VARS['key'] as the value. You can then check for the corresponding $HTTP_GET_VARS in your code.

As in any case when accepting input from "the outside" and including it in your code, proper validation of the input is required for script integrity.

Hope this helps,

SK