Compatible with DokuWiki
No compatibility info given!
Plugin name contains underscore, will not generate popularity points.
Similar to 404manager, goto
This plugin allows you to redirect users between pages and namespaces by adding a particular pattern to a page.
To cut down on the work needed when updating this plugin, I have decided to keep downloads, install, usage, history and so on, on my own site. Since that wiki isn't open to be edited without a user, I figured it would be best to leave discussion, ideas, bugs here. You are also welcome to email me. — David Lorentsen 2007-01-24 20:12
After the plugin is installed, a simple code redirects to another page:
~~REDIRECT>namespace:page~~
I'm not sure if this is the current source, but I'm adding it here as the author's link seems to be returning a 404 not found error. — Christopher Smith 2008/12/11 14:13
<?php /** * Action Plugin: Redirects page requests based on content * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author David Lorentsen <zyberdog@quakenet.org> */ if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'action.php'); /** * All DokuWiki action plugins need to inherit from this class */ class action_plugin_page_redirect extends DokuWiki_Action_Plugin { /** * return some info */ function getInfo(){ return array( 'author' => 'David Lorentsen', 'email' => 'zyberdog@quakenet.org', 'date' => '2006-11-09', 'name' => 'Page Redirector', 'desc' => 'Redirects page requests based on content', 'url' => 'http://wiki.splitbrain.org/plugin:page_redirector', ); } function register(&$controller) { $controller->register_hook('ACTION_ACT_PREPROCESS','BEFORE', $this, 'handle_page_redirect'); } function handle_page_redirect(&$event, $param) { global $ID; if ($event->data == 'show') { if (isset($_GET['redirect']) && $_GET['redirect'] == 'no') { return; } $file = wikiFN($ID,''); $content = io_readfile($file); if (preg_match('/~~REDIRECT>([a-zA-Z0-9_\-:]+)~~/', $content, $matches)) { header("Location: ".wl($matches[1],'',TRUE)); } } } } //Setup VIM: ex: et ts=4 enc=utf-8 :
The Portuguese-BR translations:
<?php /** * Portuguese-br language for Page Redirect plugin */ $lang['redirect_to'] = "Esta página é um redirecionador para %s."; $lang['redirected_from'] = "Você foi redirecionado de %s.";
— Juliano Cezar 2011/08/19 09:20
For plugin version 2007-01-24.
<?php /** * Traditional Chinese language for Page Redirect plugin * * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author: Danny Lin <danny0838[at]pchome[dot]com[dot]tw> */ $lang['redirect_to'] = "本頁已重定向至 %s。"; $lang['redirected_from'] = "本頁重定向自 %s。";
<?php /** * Traditional Chinese for Page Redirect plugin * * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author: Danny Lin <danny0838[at]pchome[dot]com[dot]tw> */ $lang['show_note'] = '在重定向目標頁顯示提示?';
<?php /** * Traditional Korean for Page Redirect plugin * * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author: David Lorentsen <zyberdog@quakenet.org> */ $lang['redirect_to'] = "이 페이지는 옮겨졌습니다. 새로운 페이지는 %s입니다."; $lang['redirected_from'] = "%s에서 넘어왔습니다.";
<?php /** * Traditional Korean for Page Redirect plugin * * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author: David Lorentsen <zyberdog@quakenet.org> */ $lang['show_note'] = '리디렉션되는 페이지에 메모를 표시할까요?';
— wincomiwincomi
2012/01/27 09:25
I use the vector template, so I prefer a wikipedia look, I modified the css so it looks like wikipedia:
.dokuwiki div.noteredirect { color: #7D7D7D; font-size: 84%; line-height: 1.2em; margin: 1em 0 1.4em 1em; width: auto; }
Also, the Dutch translations:
<?php /** * Dutch language for Page Redirect plugin */ $lang['redirect_to'] = "De pagina is verplaatst. De nieuwe locatie is %s."; $lang['redirected_from'] = "Doorverwezen vanaf %s.";
— Theo-KTheo-K
Emmen, Nederland 2010/12/29 10:22
The wantedpages.php script breaks with this plugin:
ornellas@pound:~/ornellas.apanela.com/dokuwiki/bin$ php wantedpages.php Fatal error: Call to undefined function html_wikilink() in /home/.karamazov/ornellas/ornellas.apanela.com/dokuwiki/lib/plugins/pageredirect/syntax.php on line 50 ornellas@pound:~/ornellas.apanela.com/dokuwiki/bin$
To fix it, edit lib/plugins/pageredirect/syntax.php. After the first require_once add:
require_once(DOKU_INC.'inc/html.php');
This should solve the issue.
I have the same problem when using EasyPHP, though addingrequire_once(DOKU_INC.'inc/html.php');doesn't seem to work for me?
— Theo-KTheo-K
Emmen, Nederland 2011/01/07 11:04
I had a problem with this plugin. One of pages was using it to redirect user to other page (A → B), but later I decided to “switch” pages and make the redirection work in the other direction: B → A. I removed redirection line from page A and added text onto this page; then removed text from site B and added a redirection line. All I get was a loop redirection (stopped after 5 redirections). Disabling and enabling or even reinstalling the plugin did not help…
Anyone solved this?
Solution: Open the redirect page you want to edit with the parameter ”?redirect=no” in the URL and you will get the page without getting redirected. — Markus Frosch 2008/08/06 10:17
Maybe an idea to lift this one from devel status so that it can be added to http://wikimatrix.org ? I just can't stand the idea that it is not available in DokuWiki
If you redirect something it keeps redirecting even if you uninstall and reinstall a fresh plugin….does anyone know where the heck this data is stored so I can go in and change it.Did you try ~~NOCACHE~~ on the redirected page?
For me the notice that I was redirected didn't display on the page. It's cause by the session not being started. The solution is to add session_start(); just underneath require_once(DOKU_PLUGIN.'action.php'); and comment out the other line that says session_start(); just above $_SESSION[DOKU_COOKIE]['redirect'] = $ID; — Ryan McCue
There's a slight problem with the plugin: if the page has a period in it's name the plugin won't work. Could you make it accept periods in the title? -Claws
I confirm. — Floriang 2009/05/17 18:44
The code you append to the URL to stop the redirect is ”&redirect=no”. -tjones
Redirecting to pages with Cyrillic names won't work! :( Can anyone help to solve this issue? -lolmaus
I've made patch that will allow anything in redirected page name, it works as the link is converted to wiki path internally
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/dokuwiki-plugin-pageredirect-pagematch.patch
— Elan Ruusamäe 2008/01/25 11:41
It says for build-2: “Optional text to tell the user he has been redirected.” Where is this described? I found no hints anywhere?! Bernd, April 16, 2008, 14:19
Is there a way to make the “Index” page exclude redirects? Thanks, – Matthew Pietz, 2008-07-22 14:17:23
Developer, do you plan on updating the plugin to merge the bug fix for the wantedpages.php script bug? The patch is in this page, only a merge is needed. Please update if you can. — Dace 2008/11/05 13:10
For me I changed the regex from ”~~REDIRECT>[a-zA-Z0-9_\-:]+~~” to ”~~REDIRECT>[a-zA-Z0-9_\-:\.]+~~”, because in my wiki I have pagenames including ”.”. Is there a reason why hasn't been done in the original plugin? Dominik, 13.11.2008
This plugin sends my webserver into an infinite loop when I try to access (or even link to) a page with a redirect on it while useheading is enabled.
I managed to change this plugin so that it accepts the quasi-standard ”#REDIRECT namespace:pagename” (or even ”#REDIRECT namespace/pagename”) syntax for the declaration. This is how:
Step 1: Change line #39 of syntax.php from this:
$this->Lexer->addSpecialPattern('~~REDIRECT>[a-zA-Z0-9_\-:]+~~', $mode, 'plugin_pageredirect');
To this:
$this->Lexer->addSpecialPattern('#REDIRECT .+', $mode, 'plugin_pageredirect');
Step 2: Change line #47 of syntax.php from this:
$page = substr($match,11,-2);
To this:
$page = substr($match,10,-1);
Seems to work just fine for me, although I haven't exactly stress-tested it or anything. You can grab a zipfile (which should work with Plugin Manager) with this revision included at http://nwcs.com/~jvc/pageredirect_modified.zip.
— Jo Valentine-Cooper, 2 August 2009
Thanks for David Lorentsen and Jo Valentine-Cooper. Now it works on multi-byte characters page. 1 January 2010 —raychani
Please correct your CSS.
The following lines are not valid:
style.css
-moz-border-radius: 10px; -khtml-border-radius: 10px; border-radius: 10px;
— flamflam
Aachen 2011/01/05 12:13
I made a fix so that it supports non-ASCII pagenames, also for supporting . .. : shortcuts.
Fix the following lines in syntax.php:
Find:
$this->Lexer->addSpecialPattern('~~REDIRECT>[a-zA-Z0-9_\-:]+~~', $mode, 'plugin_pageredirect');
Replace with:
$this->Lexer->addSpecialPattern('~~REDIRECT>[^\n~]+~~', $mode, 'plugin_pageredirect');
Find:
function handle($match, $state, $pos, &$handler) { // extract target page from match pattern $page = substr($match,11,-2); // prepare message here instead of in render $message = '<div class="noteredirect">'.sprintf($this->getLang('redirect_to'), html_wikilink($page)).'</div>'; return Array($page, $message); }
Replace with:
function handle($match, $state, $pos, &$handler) { global $NS; // extract target page from match pattern $page = substr($match,11,-2); resolve_pageid($NS,$page,$exists); // prepare message here instead of in render $message = '<div class="noteredirect">'.sprintf($this->getLang('redirect_to'), html_wikilink($page)).'</div>'; return Array($page, $message); }
— danny0838danny0838
2011/01/12 11:08
diff -ruN pageredirect.old/action.php pageredirect/action.php --- pageredirect.old/action.php 2007-01-24 12:36:36.000000000 +0100 +++ pageredirect/action.php 2011-01-13 14:39:42.000000000 +0100 @@ -65,7 +65,11 @@ } // redirect - header("Location: ".wl($page, Array('redirect' => $redirect), TRUE, '&')); + $anchor=''; + $tmp=explode('#',$page,2); + $page=$tmp[0]; + $anchor=$tmp[1]; + header("Location: ".wl($page, Array('redirect' => $redirect), TRUE, '&').'#'.$anchor); exit(); } } diff -ruN pageredirect.old/syntax.php pageredirect/syntax.php --- pageredirect.old/syntax.php 2007-01-24 12:36:50.000000000 +0100 +++ pageredirect/syntax.php 2011-01-13 08:40:36.000000000 +0100 @@ -36,7 +36,7 @@ function getSort() { return 1; } function connectTo($mode) { - $this->Lexer->addSpecialPattern('~~REDIRECT>[a-zA-Z0-9_\-:]+~~', $mode, 'plugin_pageredirect'); + $this->Lexer->addSpecialPattern('~~REDIRECT>[a-zA-Z0-9_\-:#]+~~', $mode, 'plugin_pageredirect'); } /**
— einhirnChristian Marg
einhirn
2011/01/13 14:48
This plugin manages to add a note before template parsing. Thus it may conflict with other plugins that use “TPL_ACT_RENDER” “BEFORE” event hook. It conflicts with asiansearch as far as I know.
We can fix it by making this plugin go first, edit action.php:
Find:
$controller->register_hook('PARSER_METADATA_RENDER','BEFORE', $this, 'handle_pageredirect_metadata');
Replace with:
$controller->register_hook('PARSER_METADATA_RENDER','BEFORE', $this, 'handle_pageredirect_metadata'); // This plugin goes first $hooks =& $controller->_hooks[TPL_ACT_RENDER_BEFORE]; if ( $hooks[0][0] != $this) array_unshift( $hooks, array_pop($hooks) );
— danny0838danny0838
2011/01/12 10:45
Please Add this:
header("HTTP/1.1 301 Moved Permanently");
to your Redirect… else redirect will not recognized by spiders.
I have dokuwiki 2009-12-25c “Lemming” running on a debian server. After updating PHP from 5.2.6 to 5.3.3 I get this error message:
So I inserted a check on line 94 before the unset:
if ( isset ( $event->data->meta['relation']['isreplacedby'] ) ) { unset .. }
Maybe this should be corrected in a coming version. Bernd
Justcoded your fix, because dokuwiki otherwise replaces –> by →, making copy and paste fail. – ojdo 2011/10/25
Since there's no package more recent than the 2007 version, anyone objecting if I integrate some of the above fixes and suggestions in a new package for download? – — Luis Machuca Bezzaza
Luis Machuca Bezzaza
ryan.chappelle
Temuco, Chile 2012/01/20 17:38