Urgent help needed: Made a failure with renaming titles!
Urgent help needed: Made a failure with renaming titles!
Hello folks,
made a big mistake. I renamed my titles the articles. The problem is, is activated smart urls. Some of those urls are indexed in Google.
If Google-Bot visits my site, he will also have the old links in his index. So he will kick them because of double contentent.
The problem depends on the IDs, no matter what is after that IDs the correct article is choosen. So Google have two diffrent links with the same content.
Please help me to fix that. The solution is.
1. take ID and title from url
2. ID and title given by url are the same? Fine->nothing to do
3. If not take the new title build an url and move with header location 302 to that page.
Where must I input that? I can code PHP. So you don´t need to give me the source code. I just wanna know where to put that thing and what is to consider.
If I had time, I could do that by myself. The problem is that Google visits my page every day. So I´am in a big hurry.
Please help me!
made a big mistake. I renamed my titles the articles. The problem is, is activated smart urls. Some of those urls are indexed in Google.
If Google-Bot visits my site, he will also have the old links in his index. So he will kick them because of double contentent.
The problem depends on the IDs, no matter what is after that IDs the correct article is choosen. So Google have two diffrent links with the same content.
Please help me to fix that. The solution is.
1. take ID and title from url
2. ID and title given by url are the same? Fine->nothing to do
3. If not take the new title build an url and move with header location 302 to that page.
Where must I input that? I can code PHP. So you don´t need to give me the source code. I just wanna know where to put that thing and what is to consider.
If I had time, I could do that by myself. The problem is that Google visits my page every day. So I´am in a big hurry.
Please help me!
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Urgent help needed: Made a failure with renaming titles!
Hi!
You can simply enter your serendipity configuration and there remove the %id% frmo the permalink path to your articles. Then only the true article titles will be used for permalink pattern recognition.
The reason is that if %id% is present, serendipity doesn't bother what else is in the title of the URL, as you already noted. Usually this is good, because of you rename an article, the old URL would no longer be found without the %ID%!
If you want to get your hands into code, check the include/functions_permalink.inc.php file with its functions. If you know PHP, you should get quite familar, the functions are documented what they do.
There you would be able to insert your 302 header relocation. Of course you could also create a plugin that listens on frontend_configure event, then make your permalink matching and if it is disjunct you can 302 redirect to the proper page. Thinking about this, this would be the much wiser thing to do instead of patching code.
You can have a look at the "serendipity_event_custom_permalinks" plugin, which already does something similar.
Best regards,
Garvin
You can simply enter your serendipity configuration and there remove the %id% frmo the permalink path to your articles. Then only the true article titles will be used for permalink pattern recognition.
The reason is that if %id% is present, serendipity doesn't bother what else is in the title of the URL, as you already noted. Usually this is good, because of you rename an article, the old URL would no longer be found without the %ID%!
If you want to get your hands into code, check the include/functions_permalink.inc.php file with its functions. If you know PHP, you should get quite familar, the functions are documented what they do.
There you would be able to insert your 302 header relocation. Of course you could also create a plugin that listens on frontend_configure event, then make your permalink matching and if it is disjunct you can 302 redirect to the proper page. Thinking about this, this would be the much wiser thing to do instead of patching code.
You can have a look at the "serendipity_event_custom_permalinks" plugin, which already does something similar.
Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Hello Garv
this is my quick patch for serendipity redirect problem:
Not perfect because I have not found the constant for the url:
What do you think?
this is my quick patch for serendipity redirect problem:
Not perfect because I have not found the constant for the url:
Code: Select all
/* BEGIN 301 HACK
* Place after in index.php after $title = serendipity_db_query(SELECT title FROM...
*/
$foo = substr($serendipity['uriArguments'][1], strpos($serendipity['uriArguments'][1], '-') + 1, strlen($serendipity['uriArguments'][1]));
if($title[0] != $foo) {
$fooURL = 'http://www.entwickler-blog.de/'.$serendipity['uriArguments'][0].'/'.$id.'-'.$title[0].'.html';
header('HTTP/1.1 301 Moved Permanently');
header('Location: '.$fooURL);
}
/* END 301 HACK */
-
i.speiser
- Regular
- Posts: 34
- Joined: Fri Sep 01, 2006 5:37 pm
- Location: Saarbrücken, Germany
- Contact:
@foobar: I case you have problems with google indexing your page properly (be it because of urls changing or other reasons) you may consider to use the Google Sitemap plugin.
In case there is a serious error in the google index relating your site, you may also apply for deleting it from the index. The procedure is described here: http://www.google.com/support/webmaster ... topic=8459
Regards
Iris
In case there is a serious error in the google index relating your site, you may also apply for deleting it from the index. The procedure is described here: http://www.google.com/support/webmaster ... topic=8459
Regards
Iris
I think I did it:
Code: Select all
/* BEGIN 301 HACK
* Place after in index.php after $title = serendipity_db_query(SELECT title FROM...
*/
$fooURLTitle = str_replace('.html', '', basename($_SERVER['REQUEST_URI']));
$fooURLTitle = substr($fooURLTitle, strpos($fooURLTitle, '-') + 1, strlen($fooURLTitle));
$fooTitle = serendipity_makeFilename($title[0]);
if($fooTitle != $fooURLTitle) {
if($fooTitle == 'unknown') {
$httpStatus = 'HTTP/1.1 404 Not Found';
$fooURL = 'http://www.entwickler-blog.de';
} else {
$httpStatus = 'HTTP/1.1 301 Moved Permanently';
$fooURL = 'http://www.entwickler-blog.de/'.$serendipity['uriArguments'][0].'/'.$id.'-'.$fooTitle.'.html';
}
header($httpStatus);
header('Location: '.$fooURL);
}
/* END 301 HACK */
Last edited by foobar on Thu Sep 07, 2006 3:05 pm, edited 1 time in total.
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Hi!
You don't need the hack, you could build your own plugin with it. Have a look at the plugin I mentioned, then you don't need all that URL obfuscating code you posted.
(but your solution should work, I agree to that. But having it as a plugin will make it easier for you to upgrade s9y at a later point)
Regards,
Garvin
You don't need the hack, you could build your own plugin with it. Have a look at the plugin I mentioned, then you don't need all that URL obfuscating code you posted.
(but your solution should work, I agree to that. But having it as a plugin will make it easier for you to upgrade s9y at a later point)
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Sure you right Garvin,
but think, I needed that solution very very quick. Implementing the hack was not really easy in that short time, because I know nothing about the code structure of Serendipity.
If I would trying to create a plugin, I don´t know how long it would take.
So its hack. And I´am fine. If you would help me a little bit out. I would create a plugin for Serendipity, so that all the ppl could easily use it.
What do you make of it, Garvin?
but think, I needed that solution very very quick. Implementing the hack was not really easy in that short time, because I know nothing about the code structure of Serendipity.
If I would trying to create a plugin, I don´t know how long it would take.
So its hack. And I´am fine. If you would help me a little bit out. I would create a plugin for Serendipity, so that all the ppl could easily use it.
What do you make of it, Garvin?
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Hi!
I understand the urgency.
Now that you have the hack working you might want to take a deep breath and if you have time again look into our cool plugin API? 
Best regards,
Garvin
I understand the urgency.
Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Here's a simple plugin, modified from an earlier thread:
For more information on what can be done and what hooks are required, we highly recommend checking out other plugins. Searching this forum for event_hook can find many impromptu plugins Garvin has developed for others.
Code: Select all
<?php # $Id: serendipity_event_helloworld.php 880 2006-01-27 14:40:21Z garvinhicking $
class serendipity_event_helloworld extends serendipity_event
{
var $title = PLUGIN_EVENT_HELLOWORLD_NAME;
function introspect(&$propbag)
{
global $serendipity;
$propbag->add('name', 'Hello World');
$propbag->add('description', '');
$propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking, really');
$propbag->add('version', '1.0');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'smarty' => '2.6.7',
'php' => '4.1.0'
));
//$propbag->add('groups', array('BACKEND_TEMPLATES'));
$propbag->add('event_hooks', array('frontend_display' => true));
}
function generate_content(&$title) {
$title = $this->title;
}
function event_hook($event, &$bag, &$eventData) {
global $serendipity;
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$event])) {
switch($event) {
case 'frontend_display':
echo "<H3>Hello, World!</H3>\n";
return true;
break;
default:
return false;
}
} else {
return false;
}
}
}
/* vim: set sts=4 ts=4 expandtab : */