Mw:Short URL
From Kb_JMY(晉明夷)
- Mediawiki: Short_URL
Making Short_URL for "Actions"
- Ref:
- mediawiki.org: $wgActionPaths
- mediawiki.org: Short_URL
- mwusers.com: Failed to make Short URLs for actions such as "edit" by $wgActionPaths, pls. help!
- GreenHost ticket support 2007/11/13 17:03 (GMT+8) with title "URL rewrite for subdomain access -> edit failed, pls. help!"
- Assumes:
- wiki is accessed by ------------- http://kb.mysite.org
- wiki installation directory -- "public_html/kb"
- LocalSettings.php ------------ $wgScriptPath=""; //Note: not [ $wgScriptPath="/kb"; ] as subdomain access!
- URL before rewrite ------- http://kb.mysite.org/index.php/MwDoc
- Want URL after rewrite --- http://kb.mysite.org/wiki/MwDoc
Procedures
- Step01: ".htaccess" file -- Rewrite URL for all "Actions" (e.g. view, edit, submit,...)
- RewriteRule ^/action/([a-z]*)/(.*)$ /index.php?action=$1&title=$2 [L,QSA]
- This will forward all requests to "/action/actionword/title " to "index.php?action=actionword&title=title"
- The complete ".htaccess" file should look like this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?title=$1 [L,QSA]
RewriteRule ^/action/([a-z]*)/(.*)$ /index.php?action=$1&title=$2 [L,QSA]
- Note: line3 is "/index.php?title=$1" and not "/kb/index.php?title=$1"
- Put the ".htaccess" file in "public_html/kb":
- Step02: LocalSettings.php -- add "$wgArticlePath" & "$wgActionPaths"
- Add the following lines to LocalSettings.php :
$actions = array('view', 'edit', 'watch', 'unwatch', 'delete','revert', 'rollback', 'protect',
'unprotect','info','markpatrolled','validate','render','deletetrackback','print',
'dublincore','creativecommons','credits','submit','viewsource','history','raw',
'purge');
foreach ($actions as $a) $wgActionPaths[$a] = "$wgScriptPath/wiki/$a/$1";
$wgArticlePath = "$wgScriptPath/wiki/view/$1";
- After that we can have URL like these:

