Manual:Short URL
Contents |
According to World Wide Web inventor Tim Berners-Lee, good page addresses should never change.[1] Short URLs which hide complex programming code from the page address are good for your audience. Please take a few minutes to devise a stable URL structure for your website before getting started, to reduce problems later.
[edit] Introduction
[edit] Goal
MediaWiki's default installation path usually looks something like this:
/var/www/localhost/htdocs/mediawiki/w
(installed as root user)/home/johndoe/public_html/mediawiki/w
(installed with a shared hosting provider)
MediaWiki's default page addresses looks like these examples:
http://example.org/w/index.php/Page_title
(recent versions of MediaWiki, without CGI support)http://example.org/w/index.php?title=Page_title
(recent versions of MediaWiki, with CGI support)
Using the methods outlined on this page, we can configure something like this:
http://example.org/wiki/Page_title
This is the most common configuration, same as in Wikipedia, though not the default because it requires server side modificationshttp://example.org/view/Page_title
http://wiki.example.org/view/Page_title
http://example.org/Page_title
(not recommended!)http://wiki.example.org/Page_title
(not recommended!)
[edit] Advantages & disadvantages
URLs without shortening have one minor advantage; they don't require configuration, so no matter in which hosting environment you end up, you can re-create that. However every widely used webserver is capable of being configured to use short urls, practically every paid web host should support this feature. Any host that doesn't offer you this feature is not worth your money.
The advantages of short URLs are that they hide all technical details, as is best practice for URLs[1] – among other things this means they can be kept stable when the underlying software changes. They are also easier to read, remember and manipulate for visitors.
[edit] Guides
Our official guides for short URL configuration for different web servers. Pick your webserver's configuration from this list. If you don't know what server software you are using, then it is most likely Apache
- Apache - How to configure short URLs on Apache.
- ...
[edit] Other how-to mini-guides
- These guides are old and are almost entirely bad advice. These will eventually be deleted one by one as our official guides above are created for different webservers.
Anyone is welcome to create a how-to solution page and list it below. Please use a sensible name for the page, one that fits in with the below names. When each unique solution has its own page, readers can skip complexity they do not want. Keep it simple, readable, short, with a separate page per separate solution.
To help others find out which Short URL methods really work, after trying each method please edit the page and increase the "worked" or "didn't_work" numbers for that guide and make a brief (or long, your choice) description on what went wrong by clicking the link on your number.
[edit] URL like - example.com/wiki/Page_title
[edit] Root access
These methods require that you have access to the server configuration. If you are on a shared host, you most likely don't; see the "no root access" examples instead.
- wiki/Page title -- Lighttpd rewrite--root access
x3
- wiki/Page title -- nginx rewrite--root access
x1
- wiki/Page title -- Cherokee rewrite--root access
x1
- wiki/Page title -- Windows with IIS7--root access
x1
x1
- wiki/Page title -- Saetta Web Server--root access
[edit] URL like - example.com/Page_title
![]() |
Warning: this method may create an unstable URL structure and leave some page names unusable on your wiki. See Manual:Wiki in site root directory. Please see the article Cool URIs don't change and take a few minutes to devise a stable URL structure for your web site before hopping willy-nilly into rewrites into the URL root. |
How to create example.com/Page_title URLs:
- Page title - nginx, Root Access, PHP as a CGI module
x4
- Page title -- Windows & Apache without 403 on Special Pages
x1
- Page title -- Saetta Web Server
[edit] URL like - wiki.example.com/Page_title
![]() |
Warning: this method may create an unstable URL structure and leave some page names unusable on your wiki. See Manual:Wiki in site root directory. Please see the article Cool URIs don't change and take a few minutes to devise a stable URL structure for your web site before hopping willy-nilly into rewrites into the URL root. |
How to create wiki.example.com/Page_title URLs.
[edit] Troubleshooting
[edit] No Skins
With Ubuntu 8.10 and Mediawiki 1.11.2 (and maybe later versions) if you use the Mediawiki sanctioned directions your skins may fail to load. To fix this, create a symbolic link in /var/www pointing to /var/lib/mediawiki with the value of $wgScriptPath in LocalSettings.php. If, for example, $wgScriptPath is set to "/w" then you need to run the command "sudo ln -s /var/lib/mediawiki /var/www/w".
Alternatively, try setting $wgLoadScript to the original file. If you source url is /wiki with the short url /w, set it to /wiki/load.php.
[edit] Purging cache
If you notice that your changes to $wgArticlePath
in LocalSettings.php are not being reflected in mysite.com/wiki/Main_Page, it may be due MediaWiki's caching of the links according to previous settings.
Go to mysite.com/wiki/Main_Page?action=purge to force MediaWiki to regenerate the cached links.
Also you can:
- execute the MySQL query "TRUNCATE objectcache;", or
- Ensure $wgCacheEpoch is updated (if $wgInvalidateCacheOnLocalSettingsChange is enabled all you have to do is edit LocalSettings.php to purge it)
[edit] Redirect visitor of your domain to your wiki
Drop a index.php file in your web root directory with the following lines:
<?php header( 'Location: http://yourdomain/w/' ) ; # header of web site index is located elsewhere.
Another option is to use a redirect in your Apache config file if you have mod_alias enabled:
RedirectMatch ^/$ /wiki
[edit] Tricks
[edit] See also
- Explanation of what CGI modules are
- $wgUsePathInfo - configuration setting that defines whether to use 'pretty' URLs or not
- Notes on placing your wiki installation in site root directory
[edit] External links
- Apache Module mod_rewrite at Apache.org
- MediaWiki Short URL Builder Tool - A tool that can automatically generate short url configuration more reliable than the configurations in these manual pages.
[edit] References
- ↑ 1.0 1.1 Cool URIs don't change by Tim Berners-Lee.
Language: | English • Deutsch • 日本語 • русский • 中文(简体) |
---|