DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:redirect

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:redirect [2018-09-20 05:59] – [Media redirects] Dr-Yukonplugin:redirect [2022-11-21 00:26] (current) Aleksandr
Line 2: Line 2:
  
 ---- plugin ---- ---- plugin ----
-description: Redirects page accesses to other pages or external sites using a central configuration file.+description: Redirects page accesses to other pages or external sites using a central configuration file
 author     : Andreas Gohr author     : Andreas Gohr
 email      : andi@splitbrain.org email      : andi@splitbrain.org
 type       : action, admin type       : action, admin
-lastupdate : 2017-11-05 +lastupdate : 2019-12-04 
-compatible : Lemming, Anteater, Rincewind, Angua, Adora Belle, Weatherwax, Binky, Ponder Stibbons, Hrun, Detritus+compatible : Lemming, Anteater, Rincewind, Angua, Adora Belle, Weatherwax, Binky, Ponder Stibbons, Hrun, Detritus, Greebo, Hogfather, Igor
 depends    :  depends    : 
 conflicts  conflicts 
Line 22: Line 22:
  
 Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually. Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually.
- 
-:!: Needs php 5.6+ 
  
 ===== Changes ===== ===== Changes =====
  
-[[https://github.com/splitbrain/dokuwiki-plugin-redirect/commits/master.atom|{{http://img529.imageshack.us/img529/5725/feedm.png?16x16 |Recent commits to Redirect Plugin (RSS feed)}}]]+[[https://github.com/splitbrain/dokuwiki-plugin-redirect/commits/master.atom|{{https://raw.githubusercontent.com/legacy-icons/famfamfam-silk/master/dist/png/feed.png?16x16&recache |Recent commits to Redirect Plugin (RSS feed)}}]]
 {{rss>https://github.com/splitbrain/dokuwiki-plugin-redirect/commits/master.atom date}} {{rss>https://github.com/splitbrain/dokuwiki-plugin-redirect/commits/master.atom date}}
  
 ===== Configuration/Usage ===== ===== Configuration/Usage =====
  
-The plugin stores a list of page/redirect pairs in a config file called ''redirect.conf'' in the plugin directory. This file needs to be writable by the webserver to edit it from the administration menu, section ''Other Plugins'' like the update plugin.+The plugin stores a list of page/redirect pairs in a config file called ''redirect.conf'' in DokuWiki's ''conf/'' directory. This file needs to be writable by the webserver to edit it from the administration menu, under section //Additional Plugins//.
  
 In order to implement the redirections manually, just place on the ''redirect.conf'' file lists of the old pages, followed by the new ones: In order to implement the redirections manually, just place on the ''redirect.conf'' file lists of the old pages, followed by the new ones:
Line 115: Line 113:
 > This almost does what I need it to. I'm organizing my novel notes in dokuwiki and have it broken out into namespaces. I want to be able to quickly add %%[[character_name]]%% and have it properly link to characters:protagonists:character_name. But, if I link to the character from places:town, it creates the link to places:character_name, which is obviously not where the page is. If I set up the redirect with *character_name redirecting to characters:protagonists:character_name, it does indeed redirect in every applicable instance. Unfortunately, it creates an infinite loop because the ultimate destination also contains character_name. Is there a way to modify this so that it will exclude the destination page? My PHP isn't really up to snuff. Or if there's another plugin that will have the same effect. I just don't want to create individual redirect pages for every other page in every namespace. But I really just want to be able to type the name and throw a few brackets around it without have to type in the whole name with namespaces.  --- //Matt 2014/8/27 05:56// > This almost does what I need it to. I'm organizing my novel notes in dokuwiki and have it broken out into namespaces. I want to be able to quickly add %%[[character_name]]%% and have it properly link to characters:protagonists:character_name. But, if I link to the character from places:town, it creates the link to places:character_name, which is obviously not where the page is. If I set up the redirect with *character_name redirecting to characters:protagonists:character_name, it does indeed redirect in every applicable instance. Unfortunately, it creates an infinite loop because the ultimate destination also contains character_name. Is there a way to modify this so that it will exclude the destination page? My PHP isn't really up to snuff. Or if there's another plugin that will have the same effect. I just don't want to create individual redirect pages for every other page in every namespace. But I really just want to be able to type the name and throw a few brackets around it without have to type in the whole name with namespaces.  --- //Matt 2014/8/27 05:56//
  
 +==== The fix for the fix - avoid redirect loops ====
 +(also called the collaborated double fix)
 +
 +The * Wildcard modification works quite well despite some redirect loops.
 +
 +To avoid redirect loops we added a second parameter ''redirected'' to the created URL in ''helper.php''.
 +
 +and in ''action.php'' we check for this parameter.
 +
 +This is a quick hack and straight forward.
 +
 +In ''helper.php'':
 +
 +add ''$url.="&redirected=1";''
 +
 +to the code at the very end of the file just right before ''return $url;''
 +
 +In ''action.php'':
 +
 +find the function ''handle_start'' at end of the file and add
 +
 +''if($INPUT->get->str('redirected') == '1') return;''
 +
 +right after or before 
 +
 +''if($INPUT->get->str('redirect') == 'no') return;''
 +
 +
 +now you can do something like this (see below) which without the modification will end up in an infinite loops.... now it works magically...
 +
 +
 +''index:a* index:a:a$1:''
 +or even 
 +''index:a-*b* index:ab:a-$1b$2:''
 +
 +(you may have to play around a bit to get the effect.....)
 +
 +Note: you cant use ''$0'', you have to use ''$1'' as a placeholder - but as the searchterm is stripped from ''$1'', you have to add the searchterm before the placeholder in the target definition
 +
 +(in the example above it's the ''a*''/''a$1:'' or ''a*b*''/''a$1b$2:'')
 +
 +In the example above we redirect all pages start with ''a'' to a namespace of the same name in namespace ''a''....
 +or all pages starting with ''a-*b*'' to ''ab:a-*b*'' ...
 +
 +sounds a bit weird ;) - it is!
 +
 +Best regards Volker & Lucas - 2022-03-29
 ==== Virtual Hostname Redirects ==== ==== Virtual Hostname Redirects ====
  
Line 174: Line 219:
 ==== Media redirects ==== ==== Media redirects ====
  
-Please add second admin config window for media's. I want to hold some media in the root and show it with shortened paths. Ex: +<del>Please add second admin config window for media's. Ex:</del> 
-  * page ''de/very/very/very/long/folders/path/index'' +  * <del>page ''de/folders/index''</del> 
-  * has an image with syntax %%{{./header.jpg}}%% +  * <del>has an image with syntax %%{{header.jpg}}%%</del> 
-  * (**not a %%{{/very/very/very/long/folders/path/header.jpg}}%%**!) +  * <del>but we don't use _media/de/folders/</del> 
-  * for ''_media/very/very/very/long/folders/path/header.jpg'', +  * <del>so image redirects by media-rule ''*:very:long:* very:long:$2''</del> 
-  * redirected by media-rule ''*:very:long:* very:long:$2''+  * <del>to correct path ''_media/folders/header.jpg''</del> 
 + 
 +Rewrited by root .htaccess with such rules (only for 2-letter folders!):\\ 
 +''RewriteRule ^_media/(..)/(.*)     lib/exe/fetch.php?media=$2  [QSA,L]\\ 
 +RewriteRule ^_media/(.*)              lib/exe/fetch.php?media=$1  [QSA,L]''\\ 
 +KISS principle as is.
plugin/redirect.1537415972.txt.gz · Last modified: 2018-09-20 05:59 by Dr-Yukon

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki