Difference between revisions of "MediaWiki/archive/customizing/URLs"

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Jump to navigation Jump to search
m (Reverted edits by 218.125.68.94 (Talk); changed back to last version by Woozle)
Line 1: Line 1:
[http://pasbasor.blogdiario.com/ ultram online] [http://eltc4tric.jubiiblog.de/ cheap xanax] [http://www.csun.edu/learningnet/discussion/file.php?0,file=142 free tracfone ringtones] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1030?id=atch1121 qwest ringtones] [http://ellapas.jubiiblog.de/ lipitor online] [http://forum.kharkiv.edu/SForums/topic.asp?TOPIC_ID=312&FORUM_ID=3&CAT_ID=3 cheap ultram] [http://www.csun.edu/learningnet/discussion/file.php?0,file=136 buy nexium] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$118 sony ericsson ringtones] [http://discussions.csbsju.edu/general/messages/25/xyli-236.html ativan online] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832257) xenical online] [http://www.rso.cmich.edu/prevet/messageboard/000031b1.htm generic cialis] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$91 cheap carisoprodol] [http://www.forumhosting.org/forum.php?mforum=laerzel free sagem ringtones] [http://www.rso.cmich.edu/prevet/messageboard/000031b4.htm generic meridia] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1030?id=atch1120 free nextel ringtones] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832194) but tramadol] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=317 carisoprodol online] [http://bondich.blogspot.com mixing valium and xanax] [http://eltaric.blogdiario.com/ cheap norco] [http://www.hcs.harvard.edu/~twiki/pub/Main/CoyarCharline/xikuzo.htm valium online] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=322 cyclobenzaprine online] [http://pasbasbas.jubiiblog.de/ clonazepam online] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832216) kyocera ringtones] [http://forum.kharkiv.edu/SForums/topic.asp?TOPIC_ID=317&FORUM_ID=3&CAT_ID=3 adipex online] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1031?id=atch1131 sonyericsson ringtones] [http://www.rso.cmich.edu/prevet/messageboard/000031ac.htm generic carisoprodol] [http://www.csun.edu/learningnet/discussion/file.php?0,file=130 hydrocodone online] [http://www.hcs.harvard.edu/~twiki/pub/Main/AngelKristofer/ronut.htm free sony ericsson ringtone] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=334 cheap meridia] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1030?id=atch1108 cheap zanaflex] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1031?id=atch1129 cingular ringtones] [http://raccaelt.jubiiblog.de/ cheap viagra] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=369 wwe ringtones] [http://www.hcs.harvard.edu/~twiki/pub/Main/AngelKristofer/digesyv.htm free nokia ringtones] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832225) free mtv ringtones] [http://eltvivi.blogdiario.com/ cheap vicodin] [http://www.hcs.harvard.edu/~twiki/pub/Main/CoyarCharline/bipivu.htm generic meridia] [http://www.forumhosting.org/forum.php?mforum=getcoro sony ericsson ringtones] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832238) sagem ringtones] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832236) qwest ringtones] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832243) sony ringtones] [http://www.forumhosting.org/forum.php?mforum=coephrai cheap tramadol] [http://www.rso.cmich.edu/prevet/messageboard/000031d2.htm qwest ringtones] [http://letocoer.jubiiblog.de/ polyphonic ringtones] [http://forum.kharkiv.edu/SForums/topic.asp?TOPIC_ID=310&FORUM_ID=3&CAT_ID=3 but xanax] [http://www.csun.edu/learningnet/discussion/file.php?0,file=155 free sagem ringtones] [http://www.hcs.harvard.edu/~twiki/pub/Main/AngelKristofer/ciby.htm free funny ringtone] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=356 sony ericsson ringtones] [http://www.csun.edu/learningnet/discussion/file.php?0,file=121 viagra online] [http://www.csun.edu/learningnet/discussion/file.php?0,file=141 free free ringtones] [http://ricrotroc.blogdiario.com/ samsung ringtones] [http://eltlili.jubiiblog.de/ buy ambien] [http://ouglova.blogspot.com valium half life] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832248) ultram online] [http://www.csun.edu/learningnet/discussion/file.php?0,file=157 free sony ericsson ringtones] [http://www.hcs.harvard.edu/~twiki/pub/Main/CoyarCharline/rujop.htm generic phentermine] [http://woolygrrl.blogspot.com valium side effects] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$134 valium online] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$95 diazepam online] [http://www.hcs.harvard.edu/~twiki/pub/Main/AngelKristofer/tubonyh.htm samsung ringtones] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1030?id=atch1113 cheap hoodia] [http://acdronou.jubiiblog.de/ cheap diazepam] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832224) free mp3 ringtones] [http://alcodom.blogdiario.com/ cheap viagra] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=370 xanax] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832241) soma online] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=312 adipex] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=318 order cialis] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1030?id=atch1105 pharmacy online online] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1029?id=atch1066 cheap soma] [http://coracou.jubiiblog.de/ hydrocodone online] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1029?id=atch1094 didrex online] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1029?id=atch1087 lorazepam online] [http://www.forumhosting.org/forum.php?mforum=covarrel funny ringtones] [http://lasitdron.jubiiblog.de/ cheap sildenafil] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1029?id=atch1084 levitra online] [http://www.hcs.harvard.edu/~twiki/pub/Main/AngelKristofer/nyzihyp.htm free tracfone ringtone] [http://manka-kapak.blogspot.com casino craps online] [http://www.rso.cmich.edu/prevet/messageboard/000031c8.htm free ringtone] [http://www.forumhosting.org/forum.php?mforum=oudronacel cheap didrex] [http://www.hcs.harvard.edu/~twiki/pub/Main/CoyarCharline/kukoti.htm generic cialis] [http://www.hcs.harvard.edu/~twiki/pub/Main/AngelKristofer/sinyfu.htm free mp3 ringtone] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832228) free nextel ringtones] [http://ervarli.blogdiario.com/ jazz ringtones] [http://www.csun.edu/learningnet/discussion/file.php?0,file=148 motorola ringtones] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832235) punk ringtones] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832253) buy wellbutrin] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832204) cool ringtones] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$88 free alltel ringtones] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1031?id=atch1134 free alltel ringtones] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=361 tramadol online] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$106 nokia ringtones] [http://discussions.csbsju.edu/general/messages/25/xyvi-237.html but viagra] [http://www.rso.cmich.edu/prevet/messageboard/000031b5.htm cheap adipex] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832230) cheap norco] [http://www.csun.edu/learningnet/discussion/file.php?0,file=134 order wellbutrin] [http://www.csun.edu/learningnet/discussion/file.php?0,file=132 lorazepam online] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832234) order propecia] [http://alcta.blogdiario.com/ free sprint ringtones] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1029?id=atch1092 ultracet] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1029?id=atch1100 cheap zoloft] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1031?id=atch1136 cool ringtones] [http://liboor.jubiiblog.de/ tracfone ringtones] [http://letorolac.jubiiblog.de/ free motorola ringtones] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832201) cheap cialis] [http://www.rso.cmich.edu/prevet/messageboard/000031c5.htm generic levitra] [http://domvimon.jubiiblog.de/ buy norco] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1029?id=atch1068 phentermine online] [http://ertral.jubiiblog.de/ carisoprodol] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1029?id=atch1074 cheap cialis] [http://enchanted1312.blogspot.com injecting valium] [http://www.forumhosting.org/forum.php?mforum=ricrolget music ringtones] [http://el5or5ro.blogdiario.com/ free motorola ringtones] [http://www.rso.cmich.edu/prevet/messageboard/000031c3.htm generic clonazepam] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1031?id=atch1128 polyphonic ringtones] [http://www.hcs.harvard.edu/~twiki/pub/Main/CoyarCharline/lusuli.htm cheap viagra] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$113 sagem ringtones] [http://bocoleto.jubiiblog.de/ free alltel ringtones] [http://discussions.csbsju.edu/general/messages/25/lepef-234.html diazepam online] [http://discussions.csbsju.edu/general/messages/25/dyjys-243.html adipex online] [http://discussions.csbsju.edu/general/messages/25/zisi-231.html buy xanax] [http://olorolacel.blogdiario.com/ cheap diazepam] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832220) cheap meridia] [http://www.forumhosting.org/forum.php?mforum=vartrocvi verizon ringtones] [http://www.forumhosting.org/forum.php?mforum=safunder viagra online] [http://algettr.blogdiario.com/ cheap carisoprodol] [http://www.rso.cmich.edu/prevet/messageboard/000031b7.htm generic vicodin] [http://forum.kharkiv.edu/SForums/topic.asp?TOPIC_ID=315&FORUM_ID=3&CAT_ID=3 viagra online] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$96 cheap fioricet] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1030?id=atch1112 flexeril online] [http://www.hcs.harvard.edu/~twiki/pub/Main/CoyarCharline/jeziluc.htm adipex online] [http://forum.kharkiv.edu/SForums/topic.asp?TOPIC_ID=302&FORUM_ID=3&CAT_ID=3 soma online] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832222) free mono ringtones] [http://tavidel.blogdiario.com/ sony ericsson ringtones] [http://www.forumhosting.org/forum.php?mforum=yohiatt buy meridia] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$135 verizon ringtones] [http://www.hcs.harvard.edu/~twiki/pub/Main/AngelKristofer/pixe.htm cingular ringtones] [http://livisit.blogdiario.com/ cheap valium] [http://www.hcs.harvard.edu/~twiki/pub/Main/AngelKristofer/pypybug.htm free nextel ringtones] [http://www.hcs.harvard.edu/~twiki/pub/Main/AngelKristofer/cicyfi.htm polyphonic ringtones] [http://boricdom.blogdiario.com/ free nextel ringtones] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$107 order norco] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=335 midi ringtones] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$100 meridia online] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=351 real ringtones] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=323 diazepam online] [http://roacpas.jubiiblog.de/ ultram] [http://cnac4tco.blogdiario.com/ free mp3 ringtones] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1029?id=atch1081 alprazolam] [http://www.rso.cmich.edu/prevet/messageboard/000031da.htm free samsung ringtones] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=359 free sprint ringtones] [http://cozelrol.jubiiblog.de/ xenical online] [http://olobasno.jubiiblog.de/ free samsung ringtones] [http://www.csun.edu/learningnet/discussion/file.php?0,file=126 alprazolam online] [http://domrelchi.jubiiblog.de/ cheap nexium] [http://cnatadel.blogdiario.com/ buy xanax] [http://www.rso.cmich.edu/prevet/messageboard/000031d7.htm free motorola ringtones] [http://www.csun.edu/learningnet/discussion/file.php?0,file=128 but paxil] [http://vizelsit.jubiiblog.de/ free free ringtones] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1029?id=atch1099 cheap lisinopril] [http://discussions.csbsju.edu/general/messages/25/wykypof-226.html tramadol online] [http://www.hcs.harvard.edu/~twiki/pub/Main/CoyarCharline/nikol.htm ultram online] [http://www.forumhosting.org/forum.php?mforum=wiwhistl cheap vicodin] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1029?id=atch1076 viagra online] [http://kleinerachel.blogspot.com valium ativan] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832210) online fioricet] [http://www.forumhosting.org/forum.php?mforum=aceldarro sonyericsson ringtones] [http://cnacorel.blogdiario.com/ free mono ringtones] [http://eltrli.jubiiblog.de/ vicodin online] [http://www.csun.edu/learningnet/discussion/file.php?0,file=120 ativan] [http://taoudel.blogdiario.com/ buy sildenafil] [http://www.csun.edu/learningnet/discussion/file.php?0,file=159 alltel ringtones] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=365 verizon ringtones] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=338 mp3 ringtones] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1029?id=atch1098 albuterol] [http://www.hcs.harvard.edu/~twiki/pub/Main/AngelKristofer/colivew.htm alltel ringtones] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1030?id=atch1119 mp3 ringtones] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832203) clonazepam online] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=352 free sagem ringtones] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=345 cheap paxil] [http://wildomania.blogspot.com ambien sleep walking] [http://eltsitzel.blogdiario.com/ free sagem ringtones] [http://www.forumhosting.org/forum.php?mforum=cnataco nokia ringtones] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=367 cheap vicodin] [http://forum.kharkiv.edu/SForums/topic.asp?TOPIC_ID=318&FORUM_ID=3&CAT_ID=3 cheap norco] [http://boroltroc.jubiiblog.de/ funny ringtones] [http://dar5or5tr.blogdiario.com/ free midi ringtones] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=363 ultram online] [http://domdronpas.blogdiario.com/ cheap tramadol] [http://www.hcs.harvard.edu/~twiki/pub/Main/CoyarCharline/nenopo.htm tramadol online] [http://www.hcs.harvard.edu/~twiki/pub/Main/CoyarCharline/xoky.htm generic paxil] [http://ginny-potter21.blogspot.com caribbean casino gold online] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1030?id=atch1109 cheap diethylpropion] [http://www.csun.edu/learningnet/discussion/file.php?0,file=137 online ultracet] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$94 clonazepam online] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832215) free jazz ringtones] [http://capasget.jubiiblog.de/ sagem ringtones] [http://www.hcs.harvard.edu/~twiki/pub/Main/CoyarCharline/kifily.htm ativan online] [http://www.forumhosting.org/forum.php?mforum=troctapas free mtv ringtones] [http://skyph0ne.blogspot.com bonus casino free online] =={{hide|navbar}}==
+
=={{hide|navbar}}==
 
{{web software|MediaWiki}}: [[MediaWiki customization|customization]]: [[shortening MediaWiki URLs]]{{sidebar|__TOC__}}
 
{{web software|MediaWiki}}: [[MediaWiki customization|customization]]: [[shortening MediaWiki URLs]]{{sidebar|__TOC__}}
 
==Overview==
 
==Overview==
Line 12: Line 12:
 
First, the .htaccess file needs to include:
 
First, the .htaccess file needs to include:
 
{{quoteon}}
 
{{quoteon}}
:
+
:<IfModule [[mod_rewrite]].c>
 +
::RewriteEngine on
 +
::
 +
::RewriteCond %{REQUEST_FILENAME} !-f
 +
::RewriteCond %{REQUEST_FILENAME} !-d
 +
::RewriteRule ^(.*)$ index.php/$1 [L,QSA]
 +
:</IfModule>
 +
{{quoteoff}}
 +
 
 +
Second, modify LocalSettings.php:
 +
:$wgArticlePath      = "/$1";
 +
 
 +
Then do ?action=purge on any page to test it. Internal links on existing pages will convert to the new URLs any time they are saved or purged.
 +
 
 +
The above seems to work for everything (including editing) without breaking old-style URLs, and may offer clues as to how to fix the minor problems which make the 404 method (below) unusable.
 +
 
 +
==Using a 404 Handler==
 +
''At this point, I can't recommend this method unless nothing else works. If you try this method, please report back on how it goes. --[[User:Woozle|Woozle]] 18:46, 29 June 2006 (EDT)''
 +
 
 +
It uses the 404 (missing page) redirect mechanism — a standard /index.php/ request is handled by the standard code (in index.php), but any other URL which doesn't correspond to an existing page (within the wiki or not) is handled by a modified index.php. For any given "nonexistent" URL of the form "http://yourdomain.com/nonexistent/page", the code returns a wiki page entitled "Nonexistent/page", with the "nonexistent" URL displayed as the URL for that page.
 +
 
 +
There is also a feature wherein you can create a page called [[Mediawiki:your/url/here]] and it will redirect to an article whose title is the ''contents'' of that page. For example: http://wiki.vbz.net/Currentevents is redirected to [[vbzwiki:Current events]] because the page [[vbzwiki:MediaWiki:Currentevents]] contains the text "Current events".
 +
 
 +
'''First''', in the main [[.htaccess]] file (or in httpd.conf if you prefer), assign a location to handle 404 errors such that a PHP file will be loaded -- either of these will do, for example:
 +
<pre>
 +
ErrorDocument 404 /errors/404/
 +
ErrorDocument 404 /wiki404error.php
 +
</pre>
 +
In the first instance, your modified index.php file would go in /errors/404/; in the second, it would be renamed wiki4040error.php and go in the same folder as the normal index.php.
 +
 
 +
The remaining instructions depend on which MediaWiki version you are using.
 +
===Version 1.4===
 +
''These instructions were made from changes that actually worked, but I may have left out some steps. I was more careful when I did the changes for version 1.5, so if these don't work check the version 1.5 instructions for anything missing.''
 +
 
 +
'''Second''': Make the changes indicated in the 404-handling copy of index.php:
 +
<pre>
 +
if ( '' == $title && 'delete' != $action ) {
 +
## 2005-06-19 Woozle mods for "missing" page
 +
# title not passed in parameter; use REQUEST_URI from environment
 +
$title = rawurldecode(ltrim($_SERVER['REQUEST_URI'], " /"));
 +
# see if there's a page designated for this URI
 +
$wgTitle = Title::newFromText( wfMsgForContent( $title ) );
 +
if ('' == $wgTitle) {
 +
$wgTitle = Title::newFromText( $title );
 +
}
 +
## end Woozle mods
 +
} elseif ( $curid = $wgRequest->getInt( 'curid' ) ) {
 +
</pre>
 +
 
 +
<pre>
 +
/* redirect to canonical url, make it a 301 to allow caching */
 +
$wgOut->setSquidMaxage( 1200 );
 +
# 2005-06-21 Woozle mods to allow 404 page to summon wiki page without redirecting
 +
# $wgOut->redirect( $wgTitle->getFullURL(), '301');
 +
$wgArticle = new Article( $wgTitle );
 +
#  $mainText = $wgOut->parse( $wgArticle->getContent( false ) );
 +
# echo $mainText;
 +
$wgArticle->view();
 +
# end Woozle mods
 +
} else if ( Namespace::getSpecial() == $wgTitle->getNamespace() ) {
 +
</pre>
 +
 
 +
===Version 1.5===
 +
'''Second''': In the same folder as the modified index.php, create a LocalSettings.php with the following contents:
 +
<?php
 +
require_once( "../../LocalSettings.php" );
 +
 +
$wgScript          = $wgScriptPath;
 +
$wgArticlePath      = "$wgScript/$1";
 +
?>
 +
 
 +
Note: "../../LocalSettings.php" works if your modified index.php is buried two folders deep from your main index.php (as in the /errors/404/index.php example); adjust it as needed to point to your main LocalSettings.php.
 +
 
 +
'''Third''': Make the changes indicated in the 404-handling copy of index.php:
 +
 
 +
* First change - need to point to the copied Defines.php:
 +
<pre>
 +
# 2005-10-25 Woozle - for 404 handling
 +
require_once( './Defines.php' );
 +
</pre>
 +
 
 +
* Second change - this is optional, but it cleans up the file a lot:
 +
<pre>
 +
# 2005-10-25 Woozle - config code removed because it will never be executed
 +
#if( !file_exists( 'LocalSettings.php' ) ) {
 +
# ...
 +
#}
 +
</pre>
 +
 
 +
* Third change - this pulls in the title-request from the error URI:
 +
# Query string fields
 +
# 2005-10-25 Woozle - 404 support - parameters have to be parsed from $_SERVER instead of $_REQUEST
 +
$raw_uri = rawurldecode(ltrim($_SERVER['REQUEST_URI'], " /"));
 +
$arr_uri = explode('?',$raw_uri);
 +
$title = $arr_uri[0];
 +
$uri_qry= $arr_uri[1];
 +
parse_str($uri_qry,$_REQUEST);
 +
$action = $wgRequest->getVal( 'action', 'view' );
 +
$title_force = $wgRequest->getVal( 'title' );
 +
if ('' != $title_force) {
 +
$title = $title_force;
 +
}
 +
# 2005-10-25 END
 +
 
 +
* Fourth change - optional and untested - allow title redirection
 +
if ( '' == $title && 'delete' != $action ) {
 +
$wgTitle = Title::newFromText( wfMsgForContent( 'mainpage' ) );
 +
# 2005-10-26 Woozle - 404 support - optional redirect based on "mediawiki:articlename"
 +
if ('' == $wgTitle) {
 +
$wgTitle = Title::newFromText( $title );
 +
}
 +
# 2005-10-26 END
 +
 
 +
* Fifth change - I'm actually not sure if this is necessary, but don't have time to test uncommenting it:
 +
# 2005-10-25 Woozle - for 404 handling - block out redirection code
 +
# was -- if ((action is explicitly "view") AND (title is not passed as param) OR (title is not in canonical form) AND ??
 +
#} else if ( ( $action == 'view' ) && (!isset( $_GET['title'] ) || $wgTitle->getPrefixedDBKey() != $_GET['title'] ) && !count( array_diff( array_keys( $_GET ), array( 'action', 'title' ) ) ) )
 +
#{
 +
# /* redirect to canonical url, make it a 301 to allow caching */
 +
# $wgOut->setSquidMaxage( 1200 );
 +
# $wgOut->redirect( $wgTitle->getFullURL(), '301');
 +
} else if ( NS_SPECIAL == $wgTitle->getNamespace() ) {
 +
===Finally===
 +
Finally, put the modified index.php where it will be the page used to handle 404 errors.
 +
 
 +
* '''Caveats''':
 +
** Your arbitrary URL will have its first character capitalized before it is displayed as the page's title or used to load another page (if you have set up a Mediawiki: page for it), although the URL shown will remain unchanged
 +
** There is probably a lot of excess index.php code which can be stripped out, as it will never be executed in this context
 +
** URLs ending in slashes appear to be a problem for some namespaces; the wiki code appears to be reading the URL from some place other than the modified code. (This doesn't seem to be a problem for version 1.5.)
 +
** <s>All wiki links on the loaded page will point back to canonical wiki URLs, e.g. http://htyp.org/wiki/index.php/Main_Page; to change this. see "Shortening the links" below.</s> 2006-02-16 This has been fixed.
 +
** <s>Image thumbnail links don't work.</s> 2006-02-16  This has been fixed.
 +
* '''2006-02-16''' Notes:
 +
** I changed the procedure a bit and page viewing now seems to work consistently, but I've only checked a few pages for proper behavior. Please test thoroughly before using on a production page, and let me know what you find.
 +
** '''Editing does not work properly'''
 +
** If certain pages persist in showing old-style links, they may be cached; add "?action=purge" to the URL to clear the cache for a given page. If you are working on an active site using the old-style links, some pages may mysteriously revert to old-style links as visitors browse them through the old-style portal, causing the old-style to be re-cached.
 +
** This method is probably not very compatible with most webstats generators, but I haven't tried it long enough to see what happens. Probably all pages will be logged as 404 errors, which isn't terribly useful.
 +
 
 +
'''Note about CPU load''': Obviously it has to do the same URL translation it would normally have to do and then determine that the file doesn't exist, but that shouldn't take any more cycles than locating an existing file; for URLs containing at least one slash, it should be quicker. Given all the processing done by the MediaWiki software for loading "normal" wiki pages, I suspect the difference is negligible.
 +
 
 +
==Using a 403 [forbidden] Handler==
 +
Something I have found to work very well is to force all files except index.php to "Deny from All" and use a 403 error handler to push all requests to index.php:
 +
 
 +
An example .htaccess:
 +
Deny from All
 +
<Files "index.php">
 +
    Allow from All
 +
</Files>
 +
# NOTE: DirectoryIndex may not be necessary
 +
DirectoryIndex index.php
 +
ErrorDocument 403 /index.php
 +
 
 +
This could probably be shortened up, but I have found it works great. :-) {{anonusersig|64.110.252.116}}
 +
==Comments==
 +
Please feel free to post comments here or on the Talk page if you try any of these procedures.

Revision as of 12:35, 29 April 2007

navbar

computing: software: web: MediaWiki: customization: shortening MediaWiki URLs

Overview

There are (at least) two "standard" ways of prettifying MediaWiki URLs, documented here.

There's also another way of doing it if you have access to httpd.conf or .htaccess. It's fairly tidy and quite flexible, though I don't know how much additional load it puts on the server (see brief discussion at the end).

Using mod_rewrite

This is probably documented elsewhere, but this is what actually worked for me on a shared server where I couldn't modify httpd.conf.

This assumes MediaWiki is installed in the root of the www pages.

First, the .htaccess file needs to include:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>

Second, modify LocalSettings.php:

$wgArticlePath = "/$1";

Then do ?action=purge on any page to test it. Internal links on existing pages will convert to the new URLs any time they are saved or purged.

The above seems to work for everything (including editing) without breaking old-style URLs, and may offer clues as to how to fix the minor problems which make the 404 method (below) unusable.

Using a 404 Handler

At this point, I can't recommend this method unless nothing else works. If you try this method, please report back on how it goes. --Woozle 18:46, 29 June 2006 (EDT)

It uses the 404 (missing page) redirect mechanism — a standard /index.php/ request is handled by the standard code (in index.php), but any other URL which doesn't correspond to an existing page (within the wiki or not) is handled by a modified index.php. For any given "nonexistent" URL of the form "http://yourdomain.com/nonexistent/page", the code returns a wiki page entitled "Nonexistent/page", with the "nonexistent" URL displayed as the URL for that page.

There is also a feature wherein you can create a page called Mediawiki:your/url/here and it will redirect to an article whose title is the contents of that page. For example: http://wiki.vbz.net/Currentevents is redirected to vbzwiki:Current events because the page vbzwiki:MediaWiki:Currentevents contains the text "Current events".

First, in the main .htaccess file (or in httpd.conf if you prefer), assign a location to handle 404 errors such that a PHP file will be loaded -- either of these will do, for example:

ErrorDocument 404 /errors/404/
ErrorDocument 404 /wiki404error.php

In the first instance, your modified index.php file would go in /errors/404/; in the second, it would be renamed wiki4040error.php and go in the same folder as the normal index.php.

The remaining instructions depend on which MediaWiki version you are using.

Version 1.4

These instructions were made from changes that actually worked, but I may have left out some steps. I was more careful when I did the changes for version 1.5, so if these don't work check the version 1.5 instructions for anything missing.

Second: Make the changes indicated in the 404-handling copy of index.php:

if ( '' == $title && 'delete' != $action ) {
## 2005-06-19 Woozle mods for "missing" page
	# title not passed in parameter; use REQUEST_URI from environment
	$title = rawurldecode(ltrim($_SERVER['REQUEST_URI'], " /"));
	# see if there's a page designated for this URI
	$wgTitle = Title::newFromText( wfMsgForContent( $title ) );
	if ('' == $wgTitle) {
		$wgTitle = Title::newFromText( $title );
	}
## end Woozle mods
} elseif ( $curid = $wgRequest->getInt( 'curid' ) ) {
	/* redirect to canonical url, make it a 301 to allow caching */
	$wgOut->setSquidMaxage( 1200 );
# 2005-06-21 Woozle mods to allow 404 page to summon wiki page without redirecting
#	$wgOut->redirect( $wgTitle->getFullURL(), '301');
	$wgArticle = new Article( $wgTitle );
#  	$mainText = $wgOut->parse( $wgArticle->getContent( false ) );
#	echo $mainText;
	$wgArticle->view();
# end Woozle mods
} else if ( Namespace::getSpecial() == $wgTitle->getNamespace() ) {

Version 1.5

Second: In the same folder as the modified index.php, create a LocalSettings.php with the following contents:

<?php
require_once( "../../LocalSettings.php" );

$wgScript           = $wgScriptPath;
$wgArticlePath      = "$wgScript/$1";
?>

Note: "../../LocalSettings.php" works if your modified index.php is buried two folders deep from your main index.php (as in the /errors/404/index.php example); adjust it as needed to point to your main LocalSettings.php.

Third: Make the changes indicated in the 404-handling copy of index.php:

  • First change - need to point to the copied Defines.php:
# 2005-10-25 Woozle - for 404 handling
require_once( './Defines.php' );
  • Second change - this is optional, but it cleans up the file a lot:
# 2005-10-25 Woozle - config code removed because it will never be executed
#if( !file_exists( 'LocalSettings.php' ) ) {
# ...
#}
  • Third change - this pulls in the title-request from the error URI:
# Query string fields
# 2005-10-25 Woozle - 404 support - parameters have to be parsed from $_SERVER instead of $_REQUEST
	$raw_uri = rawurldecode(ltrim($_SERVER['REQUEST_URI'], " /"));
	$arr_uri = explode('?',$raw_uri);
	$title = $arr_uri[0];
	$uri_qry= $arr_uri[1];
	parse_str($uri_qry,$_REQUEST);
	$action = $wgRequest->getVal( 'action', 'view' );
	$title_force = $wgRequest->getVal( 'title' );
	if ( != $title_force) {
		$title = $title_force;
	}
# 2005-10-25 END
  • Fourth change - optional and untested - allow title redirection
if (  == $title && 'delete' != $action ) {
	$wgTitle = Title::newFromText( wfMsgForContent( 'mainpage' ) );
# 2005-10-26 Woozle - 404 support - optional redirect based on "mediawiki:articlename"
	if ( == $wgTitle) {
		$wgTitle = Title::newFromText( $title );
	}
# 2005-10-26 END
  • Fifth change - I'm actually not sure if this is necessary, but don't have time to test uncommenting it:
# 2005-10-25 Woozle - for 404 handling - block out redirection code
# was -- if ((action is explicitly "view") AND (title is not passed as param) OR (title is not in canonical form) AND ??
#} else if ( ( $action == 'view' ) && 	(!isset( $_GET['title'] ) || $wgTitle->getPrefixedDBKey() != $_GET['title'] ) && !count( array_diff( array_keys( $_GET ), array( 'action', 'title' ) ) ) )
#{
#	/* redirect to canonical url, make it a 301 to allow caching */
#	$wgOut->setSquidMaxage( 1200 );
#	$wgOut->redirect( $wgTitle->getFullURL(), '301');
} else if ( NS_SPECIAL == $wgTitle->getNamespace() ) {

Finally

Finally, put the modified index.php where it will be the page used to handle 404 errors.

  • Caveats:
    • Your arbitrary URL will have its first character capitalized before it is displayed as the page's title or used to load another page (if you have set up a Mediawiki: page for it), although the URL shown will remain unchanged
    • There is probably a lot of excess index.php code which can be stripped out, as it will never be executed in this context
    • URLs ending in slashes appear to be a problem for some namespaces; the wiki code appears to be reading the URL from some place other than the modified code. (This doesn't seem to be a problem for version 1.5.)
    • All wiki links on the loaded page will point back to canonical wiki URLs, e.g. http://htyp.org/wiki/index.php/Main_Page; to change this. see "Shortening the links" below. 2006-02-16 This has been fixed.
    • Image thumbnail links don't work. 2006-02-16 This has been fixed.
  • 2006-02-16 Notes:
    • I changed the procedure a bit and page viewing now seems to work consistently, but I've only checked a few pages for proper behavior. Please test thoroughly before using on a production page, and let me know what you find.
    • Editing does not work properly
    • If certain pages persist in showing old-style links, they may be cached; add "?action=purge" to the URL to clear the cache for a given page. If you are working on an active site using the old-style links, some pages may mysteriously revert to old-style links as visitors browse them through the old-style portal, causing the old-style to be re-cached.
    • This method is probably not very compatible with most webstats generators, but I haven't tried it long enough to see what happens. Probably all pages will be logged as 404 errors, which isn't terribly useful.

Note about CPU load: Obviously it has to do the same URL translation it would normally have to do and then determine that the file doesn't exist, but that shouldn't take any more cycles than locating an existing file; for URLs containing at least one slash, it should be quicker. Given all the processing done by the MediaWiki software for loading "normal" wiki pages, I suspect the difference is negligible.

Using a 403 [forbidden] Handler

Something I have found to work very well is to force all files except index.php to "Deny from All" and use a 403 error handler to push all requests to index.php:

An example .htaccess:

Deny from All
<Files "index.php">
   Allow from All
</Files>
# NOTE: DirectoryIndex may not be necessary
DirectoryIndex index.php
ErrorDocument 403 /index.php

This could probably be shortened up, but I have found it works great. :-) anonymous user 64.110.252.116

Comments

Please feel free to post comments here or on the Talk page if you try any of these procedures.