Manual:Short URL

According to World Wide Web inventor Tim Berners-Lee, good page addresses should never change. 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.

Goal
MediaWiki's default installation path usually looks something like this:
 * (installed as root user)
 * (installed with a shared hosting provider)

MediaWiki's default page addresses looks like these examples:
 * (recent versions of MediaWiki, without CGI support)
 * (recent versions of MediaWiki, with CGI support)

Using the methods outlined on this page, we can configure something like this:
 * This is the most common configuration, same as in Wikipedia, though not the default because it requires server side modifications
 * (not recommended!)
 * (not recommended!)
 * (not recommended!)
 * (not recommended!)

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, as 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 – 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.

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.

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.

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.

(for apache guidance, see the link previous to this section).

URL like - example.com/Page_title
How to create example.com/Page_title URLs:

URL like - wiki.example.com/Page_title
How to create wiki.example.com/Page_title URLs.

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.

Purging cache
If you notice that your changes to  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:
 * 1) execute the MySQL query "TRUNCATE objectcache;", or
 * 2) Ensure  is updated (if  is enabled all you have to do is edit LocalSettings.php to purge it)

Redirect visitor of your domain to your wiki
Drop a index.php file in your web root directory with the following lines:

Another option is to use a redirect in your Apache config file if you have mod_alias enabled:

RedirectMatch ^/$ /wiki

Moving a wiki from /wiki to /w
A very common mistake among newbie Wiki admins is to install the Wiki under http://example.org/wiki/ instead of http://example.org/w/. Usually these users will only become aware of the mistake when trying to configure Short URLs.

Actually moving a wiki is too complicated (specially for newbie wiki admins) if all you need is to "rename" the installation path of your wiki, so here is what you have to do.

Step by step
$wgScriptPath = "/w"; $wgScriptExtension = ".php"; $wgArticlePath = "/wiki/$1"; $wgUsePathInfo = true;
 * Make backups of your  and   files.
 * Go to shorturls.redwerks.org, type in your wiki URL and submit (please note that in order for the script to work, you need your wiki to be openly "readable". Make sure it is by looking up  in your LocalSettings.php. It must be set to  ).
 * Follow the on screen instructions for setting up  and   files.
 * Usually you will need to make sure you  contains the following lines:
 * ...and:

$wgGenerateThumbnailOnParse = false;
 * While  should have these lines:

RewriteEngine On RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L] RewriteRule ^/?$ %{DOCUMENT_ROOT}/w/index.php [L]

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d RewriteRule ^/?w/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/w/thumb.php?f=$1&width=$2 [L,QSA,B]

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d RewriteRule ^/?w/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/w/thumb.php?f=$1&width=$2&archived=1 [L,QSA,B] $wgLogo = "/w/my_cool_logo.png";
 * The code above will work for standard MediaWiki installations. Particularly, your file upload directory might be set up differently. When in doubt, follow the instructions provided by shorturls.redwerks.org!
 * Please note that after changing  your wiki will be temporarily broken.
 * Finally, rename the installation directory of your wiki on your server from  to   to get it back to its tracks.
 * If you have a custom logo, you might want to start the filename with /w/, something like this on :
 * This is a good time to perform a few tests on your wiki, to make sure nothing is broken. Edit a page, browse a little, upload a file, etc. If anything seems abnormal, revert the changes with your backups of  and.
 * If your wiki was originally private, don't forget to change  back to.

Note for shared hosting users: some shared hosting plans will offer you auto-update and auto-upgrade for installed apps like MediaWiki. On those cases it would be a good idea to drop their tech support a line to let them know you just manually changed the installation path of your MediaWiki.