27d9e6a1be9e464b907ec32f22434619eb1810dd
[atutor.git] / mods / wiki / doc / NicerUrls
1
2 If you want nicer URLs (without question marks) for your Wiki, then follow
3 the instructions below on how to set this up with the Apache web server.
4
5
6 ModRewriteUrls
7 --------------
8
9 If you want more beatiful URLs (!http://wiki.example.com/PageName) to all
10 your Wiki pages, you can either use the PathInfoUrls method or leverage the
11 power of the Apache mod_rewrite extension.
12
13 ==fragments/htaccess== provides an examplary setup. Typically it goes
14 by putting something like this into a .htaccess file near your ewiki
15 script/wrapper installation:
16
17   RewriteEngine On
18   #-- let ordinary files pass through
19   RewriteCond  %{SCRIPT_FILENAME}  !-f
20   RewriteCond  %{SCRIPT_FILENAME}  !-d
21   RewriteCond  %{SCRIPT_FILENAME}  !-l
22   #-- every other 'filename' is however treated as page name
23   RewriteRule  ^(.+)$  index.php?id=$1  [L,QSA]
24
25 So then you can set the [EWIKI_SCRIPT] config constant to the right value,
26 using ==define("EWIKI_SCRIPT", "/wiki/");== for example. Please keep in
27 mind, that it should be absolute (a slash in front), because pagenames may
28 contain slashes and action names get prefixed using a slash too.
29
30   define("EWIKI_SCRIPT", "/wiki/");
31 # define("EWIKI_USE_ACTION_PARAM", 2);  // forces ?action= param
32 # define("EWIKI_ACTION_TAKE_ASIS", 0);  // in conjunction with this
33
34 There are more paramters, that you might want/need to tweak (_URLENCODE
35 and EWIKI_DECODE for example). Please refer to the [README.config] on this.
36
37
38 virtual /wiki/ directory
39 ------------------------
40
41 The most reliable approach to get non-ugly URLs for ewiki is to use
42 a fully virtual (= simulated by mod_rewrite) path name to access
43 Wiki pages.
44
45 This example assumes you install ewiki into the DOCUMENT_ROOT
46 of yourserver. You should then put all ewiki files in a directory
47 named "ewiki". Into the .htaccess file of the DOC_ROOT directory
48 you'd put following:
49
50 <code>
51   RewriteEngine On
52   RewriteRule  ^wiki/(.*)$  ewiki/index.php?id=$1  [QSA,L]
53   RewriteRule  ^wiki$       wiki/                  [R]
54  #RewriteRule  ^wiki$    http://example.com/wiki/  [R=301,L]
55 </code>
56
57 So all pages can be accessed under the fake ==/wiki/== directory, while
58 ewiki files are actually in ==ewiki/==. The last rule should use the
59 absolute URL preferrably.
60
61 You then would configure ewiki URL and link generation accordingly in our
62 hypothetic ==ewiki/index.php== script:
63
64 <code>
65    define("EWIKI_SCRIPT", "/wiki/");
66    define("EWIKI_SCRIPT_URL", "http://www.example.com/wiki/");
67    define("EWIKI_SCRIPT_BINARY", "/ewiki/index.php?binary=");
68 </code>
69
70 Please note the difference between _SCRIPT and _SCRIPT_BINARY (if
71 you need it at all).
72
73
74 PathInfoUrls
75 ------------
76
77 Typically ewiki URLs will look like:
78
79 * ~[/wiki/index.php?id=FrontPage]
80 * ~[/wiki/index.php?id=RecentChanges]
81
82 If you can't use ModRewriteUrls, then you may wish to set the config
83 constant [EWIKI_SCRIPT] to something like "==/wiki/index.php/==" so you get
84 almost beatiful URLs to all Wiki pages:
85
86 * ~[/wiki/index.php/FrontPage]
87 * ~[/wiki/index.php/RecentChanges]
88
89 If you also have the permissions (providers often make this unusable for
90 silly reasons) to override some Apache settings, then you could put 
91 "==**Options All +MultiViews**==" into your .htaccess file. This way the
92 URLs would further beautify to;
93
94 * ~[/wiki/index/FrontPage]
95 * ~[/wiki/index/RecentChanges]
96
97 Alternatively try to create an Apache .var file (index.var which maps to
98 index.php itself). See the ApacheManual for more informations on this
99 issue.
100
101
102 simple wiki/ support
103 --------------------
104
105 If all of the above sounds still too complicated for you, or mod_rewrite is
106 not available then you could use the following trick to get prettier URLs.
107
108 Rename your yoursite.php or "index.php" to just "wiki", and create a file
109 called ".htaccess" in the same directory with following content:
110
111   <Files wiki>
112     ForceType application/x-httpd-php
113   </Files>
114   
115 This will trick Apache into parsing it as PHP script, even though the file
116 has no extension anymore.
117
118 Add following to your config.php or above script:
119
120   define("EWIKI_SCRIPT", "wiki/");
121   
122 This works like the PathInfoUrls or virtual mod_rewrite directory as
123 described above.
124