-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
123 lines (86 loc) · 3.66 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
The UrlShortener extension is a MediaWiki extension that accepts arbitrary urls
from a list of allowed domains and shortens them.
== Configuration ==
=== URL routing configuration ===
Configures the template to use when generating the shortened URL. Using this
feature will require mod_rewrite (or an equivalent). If set to false (default),
the short URLs will use the not-so-short
<code>/wiki/Special:UrlShortener/5234</code> since it will work regardless of
web server configuration.
If you wanted your short URLs in the form of <code>domain.org/r/5234</code>, you would set:
<source lang="php">
$wgUrlShortenerTemplate = '/r/$1';
</source>
=== Short domain name ===
If you have a custom short domain name, you can set it by using:
<source lang="php">
$wgUrlShortenerServer = "short.wiki";
</source>
If set to false (default), it will use $wgServer.
=== Global database ===
Set this to the name of a database if you wish to use one central database for your wiki farm.
<source lang="php">
$wgVirtualDomainsMapping['virtual-urlshortener'] = [ 'db' => 'wikishared' ];
</source>
If the database is on an external cluster, you will also need to configure that.
<source lang="php">
$wgVirtualDomainsMapping['virtual-urlshortener'] = [ 'cluster' => 'extension1', 'db' => 'wikishared' ];
</source>
=== Allow arbitrary ports ===
By default, only URLs with ports 80 and 443 are accepted and are automatically removed.
If your wiki is set up using a custom port, set this to true to allow shortening URLs
that have arbitrary ports.
<source lang="php">
$wgUrlShortenerAllowArbitraryPorts = true
</source>
=== AllowedDomains regex ===
Configures the acceptable domains that users can submit links for. This is an
array of regular expressions. If set to false (default), it will set up a allow-list for the current domain (using $wgServer).
<source lang="php">
$wgUrlShortenerAllowedDomains = false;
</source>
For example, to only allow links from wikipedia.org or wikimedia.org, we would use the following:
<source lang="php">
$wgUrlShortenerAllowedDomains = [
'(.*\.)?wikimedia\.org',
'(.*\.)?wikipedia\.org',
];
</source>
If we want to allow links from any domain:
<source lang="php">
$wgUrlShortenerAllowedDomains = [ '.*' ];
</source>
=== AllowedDomains documentation ===
To provide human-readable documentation of the list, this is an array of the allowed domains that will be displayed on Special:UrlShortener.
If set to false (default), it will output a normalized version of $wgServer.
<source lang="php">
$wgUrlShortenerApprovedDomains = false;
</source>
If you only allow wikipedia.org and wikimedia.org in the above example:
<source lang="php">
$wgUrlShortenerApprovedDomains = [
'*.wikimedia.org',
'*.wikipedia.org',
];
</source>
=== Shortcode character set ===
If you want to customize the character set the shortcodes use, you can override
this setting. If changed, any existing short URLs will go to the wrong
destination.
<source lang="php">
$wgUrlShortenerIdSet = '23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz-';
</source>
In addition, for decoding a character mapping can be specified.
This can be used to map any symbol onto another and maintain
backwards-compatibility for previously generated URLs.
The following example maps the `$` symbol to `-`:
<source lang="php">
$wgUrlShortenerIdMapping = [ '$' => '-' ];
</source>
=== Read-only mode ===
Set $wgUrlShortenerReadOnly to true to prevent users from creating new
short URLs. This is mainly intended as a hack while deploying to Wikimedia sites
and will be removed once it is no longer needed.
== License ==
© 2014 Yuvaraj Pandian ([email protected]) under the Apache 2.0 license,
see the COPYING file for the full license.