Veniamin Goldin wrote:
> Hello Mike,
>
> Thank you for your help,
>
> As I wrote already this issue is mainly because of search engines
> incompatibility with dynamic content sites (to be more exact - with
> urls containing get parameters, in my case ex.
> index.shtml?lang=en&menu_id=23)
>
> Which of your described solution would you suggest for my situation ?
>
> Turck MMCache already installed. Now I need to do something with my
> urls. There are also problem emulating search engine friendly urls
> using "/" instead of "&" because I use SSI, so I can not use post
> method in
> forms, while using GET it will be a bit difficult to handle all params
> correctly, or I'm wrong ?
>
> Thanks again.

I'm working on a solution for this problem myself, having a php bbs that
wasn't being indexed. The first thing I did was change these '?', '=', ';'
and '&' in the urls. That raised the number of indexed pages in google from
30 to 600. Then I made the urls in anchors, all relative. That raised the
indexed results to 2900. Now I'm making the urls shorter, which I believe
will raise the number many thousands.

So an anchor with a url like this
"http://www.example.com/directory/script.php?variable1=value1;variable2=2";,
is rewritten to this "script.php/variable1-value1_variable2-value2". You
have to parse that url at the beginning of your script so it can get the
variables and their values. Here's the code I wrote for this:

<?php
#get vars from friendly ulr
$arr1 = explode('/', $PATH_INFO);
$arr2 = explode('_', $arr1['1']);
foreach($arr2 as $element) {
 list($key, $value) = explode('-', $element);
 $$key = $value;
}
?>

And you have to include the <base> tag to the html head, so that the
relative urls work correctly, or they'll be wrong because of the extra
directories and confuse the location of the real script. In this example,
it'd be <base href="http://www.example.com/directory/script.php"; />. Of
course, you may have to change this a bit if there's several scripts working
in your webpage, in my bbs case, it's only one script to show every content
depending on the values in the query.

What I'm doing now, is remove as many variables as possible from the url to
make it shorter and making it look like a file. Following the example,
they'll look more or less like this:
"http://www.example.com/directory/script.php/12314-123.php";, the first
number for variable1 and the second one to variable2. Of course, you'll have
to design your url depending on your particular case, this works for me.

Another think I plan to add later, is some mod_rewrite rules to make them
even shorter and normal. With this, the las url I showed as and example, can
be changed to this "http://www.example.com/directory-12314-123.php"; or
whatever you choose. Making that url relative in the anchors, would change
it to this "/directory-12314-123.php" or .htm if you prefer it. That's a
pretty static, normal looking url, for a dynamic page. And it's in the root,
so it'll have more relevance in the search results.

The way I change the urls is not in the scripts, I use output buffering and
preg_replace the urls with the new version. I found preg_replace_callback
very comfortable for this, cause I find a url in the buffer, send it to a
function to do the modifications and return the new modified url to the same
place the old one was. I wrote different functions for this: one to change
the symbols in the urls, another to make them relative, another to use a
shorter version of the url.

I'm still new to this, so I may have written something wrong, but most of
the above I've tested and works, so you should be able to figure it out. I
hope you find something useful in what I've written. If there is something
wrong in my approach, please let me know so I improve a little. Thanks :)

Good luck.

Cristian

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to