Manual:Short URL

According to World Wide Web inventor Tim Berners-Lee, good webpage addresses should never change. Short webpage addresses which hide complex programming code from the webpage address is good for webpage visitors. Please take a few minutes to devise a stable URL structure for your website before getting started, to reduce problems later. This page has been divided into separate "how to" mini-guides listed below to make things easier.

MediaWiki's default installation path usually look like these examples:
 * (installed as root user)
 * (installed with a shared hosting provider)

MediaWiki's default webpage addresses look like these examples:
 * (MediaWiki version 1.11.0) or

Using the methods below, short webpage addresses can be changed to addresses such as these:

What's wrong with long URLs?
Before starting, we must first ask "what's wrong with long URLs?" Answer: nothing much. Indeed only long URLs work in all hosting environments -- a good thing to know if one day you move your wiki to a hosting environment where you can't use short URLs.

However, we have decided that we are willing to pay the price (trial and error configuration work as detailed below) for the admittedly purely cosmetic surgery to make our URLs look better ("pretty" vs. "ugly"). Hence we commence our journey...

Shared hosting
Most shared hosting systems do not allow changes to httpd.conf. If you are using a shared host, before trying to solve the problem yourself, first try asking your hosting provider. Your hosting provider may well solve your problem for you. If that doesn't work out, depending on your hosting provider, you may be able to make use of a .htaccess file to achieve your goals.

If you have a choice, you should edit httpd.conf, which requires root access and is the preferred method because your wiki will perform better. You only need to edit either .htaccess or httpd.conf, not both.

How to mini-guides
Anyone is welcome to create a "how to" solution page and list them 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.

example.com/Page_title
How to create: example.com/Page_title webpage addresses
 * Manual:Short URL/Page title -- PHP as a CGI module, no root access [[Image:Smiley.svg|20px]] x26 [[Image:Face-sad.svg|20px]] x5
 * Manual:Short URL/Page title -- Aliasing method--Root access [[Image:Smiley.svg|20px]]x1 [[Image:Face-sad.svg|20px]] x6
 * Manual:Short URL/Page title -- Working method with mediawiki-1.11 [[Image:Smiley.svg|20px]] x17 [[Image:Face-sad.svg|20px]]x5 used this method[[Image:Face-sad.svg|20px]] x2

example.com/wiki/Page_title
How to create: example.com/wiki/Page_title webpage addresses


 * Manual:Short URL/wiki/Page title -- PHP as a CGI module, no root access [[Image:Smiley.svg|20px]]x6 [[Image:Face-sad.svg|20px]]x3
 * Manual:Short URL/wiki/Page title -- no root access [[Image:Smiley.svg|20px]]x6 [[Image:Face-sad.svg|20px]]x3
 * Manual:Short URL/wiki/Page title -- Both no root and root access [[Image:Smiley.svg|20px]]x2

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.


 * Manual:Short URL/wiki/Page title--root access -- EASY [[Image:Smiley.svg|20px]]x9
 * Manual:Short URL/wiki/Page title -- with aliases--root access [[Image:Smiley.svg|20px]]x4 [[Image:Face-sad.svg|20px]]x2
 * Manual:Short URL/wiki/Page title -- Apache rewrite--root access[[Image:Smiley.svg|20px]]x3 If the Alias method is not suitable (for example, you use PHP as a CGI), you can use Apache instead.
 * Manual:Short URL/wiki/Page title -- Lighttpd rewrite--root access

www.example.com/sub_directory/wiki/Page_Title

 * Manual:Short URL/sub_directory/wiki/Page Title -- .htaccess [[Image:Smiley.svg|20px]]x1

wiki.example.com/Page_title
How to create: wiki.example.com/Page_title webpage addresses


 * Manual:Short URL/wiki.example.com/Page_title--difficult [[Image:Face-sad.svg|20px]]
 * Manual:Short URL/wiki.example.com/Page_title--Subdomain with no Subdirectory in Article URL [[Image:Smiley.svg|20px]]x8[[Image:Face-sad.svg|20px]]
 * Manual:Short URL/wiki.example.com/Page_title--Subdomain using mod-rewrite
 * Manual:Short URL/wiki.example.com/Page_title--Subdomain using Lighttpd
 * Manual:Short URL/wiki.example.com/Page_title--Enabling a wiki using Apache Rewrite [[Image:Smiley.svg|20px]]

Ampersand (&) problem
Explanation: This problem shows up when you have page titles with symbols in (such as &, ?, #, + and /) that, despite being correctly encoded in the link are not being passed correctly from mod_rewrite to the script. This manifests in 404 page not found errors, because the title gets cut off at the special character. e.g. Clicking on a link "John & Maria's page" gets a 404, because MediaWiki is looking for a page names "John ".

Solutions:
 * Manual:Short URL/Ampersand solution with root access
 * Manual:Short URL/Ampersand semi-friendly solution with root access

Tricks

 * Manual:Short URL/IIS6 [[Image:Smiley.svg|20px]]
 * Manual:Short URL/Prevent bots from crawling index.php
 * Manual:Short URL/Ignoring the Trailing slash
 * Manual:Short URL/Allowing for escaped characters in URI [[Image:Smiley.svg|20px]]

Troubleshooting

 * I received a looping alias/rewrite errors such as: 'Cannot find page www.example.com/wiki/wiki/wiki/wiki/wiki/ [...] /index.php' Solution: Manual:Short URL/Repeated directory errors
 * Manual:Short URL/Page title -- Working method with mediawiki-1.11