Posted on: 05/20/08 06:16am
By: beewee
When we're using url_rewrite to the article url changes from: /article.php?story=story_id&query=xxx to: /article.php/story_id.
Unfortunately the search function still generates the old /article.php?story=story_id&query=xxx. This means for Google: duplicate content.
How can I change the following code from the search class to obtain /article.php/story_id ? I'll skip the query as youn see..
Text Formatted Code
$articleUrl = COM_buildUrl ($_CONF['site_url']
. '/article.php?story=' . $A['sid']);
} else {
$articleUrl = $_CONF['site_url'] . '/article.php?story='
. $A['sid'] . '&query=' . urlencode ($urlQuery);
}
$row = array ('<a href="' . $articleUrl . '">'
. stripslashes ($A['title']) . '</a>', $thetime[0],
DB_getItem ($_TABLES['users'], 'username',
"uid = '{$A['uid']}'"), $A['hits']);
Re: Duplicate content generated by search.class.php
Posted on: 05/20/08 03:10pm
By: Dirk
Somewhat to my surprise, URLs like
Text Formatted Code
http://www.geeklog.net/article.php/geeklog-1.5.0b2?query=beta
do actually work (at least with the Apache setup here - haven't done any more testing yet). So that should be relatively easy to change (assuming it works on your server, too).
bye, Dirk
Re: Duplicate content generated by search.class.php
Posted on: 05/21/08 05:40am
By: beewee
Dirk, I've already tried that, but it didn't work on my server. And if I write a .htacces rewrite rule, it conflicts with the Geeklog URL_rewrite, resulting in an 500 internal server error.
Re: Duplicate content generated by search.class.php
Posted on: 05/21/08 01:13pm
By: jmucchiello
put a deny rule in your robots.txt for "query="
Re: Duplicate content generated by search.class.php
Posted on: 05/21/08 03:51pm
By: Dirk
Quote by: beeweeDirk, I've already tried that, but it didn't work on my server.
Too bad, it sounded like an easy way out.
We've added it to
Sami[*1] 's to-do list :wink:
bye, Dirk
Re: Duplicate content generated by search.class.php
Posted on: 05/21/08 04:34pm
By: beewee
Great, I'll be patient!
Re: Duplicate content generated by search.class.php
Posted on: 05/22/08 09:19pm
By: sbarakat
I have tested the url on a fresh install of beta 2
http://localhost/geeklog/public_html/article.php/welcome?query=geeklog
and for some reason it directs back to the home page. I will do a couple more tests and also keep the url rewrite stuff in mind when I work on the improvements to the search page. If however I find a "quick n dirty hack" I will post it up, otherwise you may have to wait until the project is finished and included in the next version of GL (1.6 maybe?)
Re: Duplicate content generated by search.class.php
Posted on: 05/23/08 03:21am
By: Dirk
Quote by: furiousdogfor some reason it directs back to the home page.
That's Geeklog's way of dealing with manipulated / illegal requests that it doesn't consider worth reporting. So on your setup, that request ended up as something that Geeklog didn't like.
bye, Dirk
Re: Duplicate content generated by search.class.php
Posted on: 05/23/08 01:32pm
By: beewee
Quote by: furiousdogI have tested the url on a fresh install of beta 2
http://localhost/geeklog/public_html/article.php/welcome?query=geeklog
and for some reason it directs back to the home page. I will do a couple more tests and also keep the url rewrite stuff in mind when I work on the improvements to the search page. If however I find a "quick n dirty hack" I will post it up, otherwise you may have to wait until the project is finished and included in the next version of GL (1.6 maybe?)
I've also tried several url_rewrites, but now I know why they didn't work out at all: Geeklog didn't like them
Re: Duplicate content generated by search.class.php
Posted on: 06/23/08 04:21pm
By: sbarakat
Sorry for the late response on this, I have been busy with other things and it completely slipped my mind.
To fix the problem open up the search.class.php file and replace this block of code
Text Formatted Code
if (empty($this->_query)) {
$articleUrl = COM_buildUrl($_CONF['site_url']
. '/article.php?story=' . $A['sid']);
} else {
$articleUrl = $_CONF['site_url'] . '/article.php?story='
. $A['sid'] . '&query=' . urlencode($this->_query);
}
with this
Text Formatted Code
$articleUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']);
if (!empty($this->_query)) {
$articleUrl .= (strpos($articleUrl,'?') ? '&' : '?') . 'query=' . urlencode($this->_query);
}
it should be around line 306.
I have tested this briefly and it seems to work when url_rewrite is enabled and disabled, let me know how you get on. Maybe this fix can be included in the future GL 1.5.0-1?
Re: Duplicate content generated by search.class.php
Posted on: 06/24/08 02:50am
By: beewee
Hey, works like a charm over here!
Thanks! :banana:
Please include this in GL1.51
Re: Duplicate content generated by search.class.php
Posted on: 06/27/08 04:19pm
By: ankur_mmy
That works on my GL 1.4.1.. cheers