According to World Wide Web inventor Tim Berners-Lee, good webpage addresses should never change.[1] Short webpage addresses which hide complex programming code from the webpage address bar is good for webpage visitors.
MediaWiki's default webpage addresses look like these examples:
http://example.com/wiki/index.php/Page_title(MediaWiki version 1.11.0) orhttp://example.com/wiki/index.php?title=Page_title
Using the methods below, short webpage addresses can be changed to addresses such as these:
http://example.com/Page_titlehttp://example.com/wiki/Page_titlehttp://wiki.example.com/Page_title
How to shorten a webpage addresses gets complicated fast. So the "how to" miniguides will be on separate pages listed below.
Contents |
Root access or no root access?
Shared Hosting: If you are using a shared host it is unlikely you will have root access to the server. You probably will not be able to use any of the root access techniques below. First try to open a ticket with your hosting provider. Ask the provider how to get rid of the "index.php?title=" for all pages and your hosting provider may well solve your problem for you.
If you do not have root access, the .htaccess, located in the public_html folder can be rewritten without root access. Depending on your host, you may be able to use an alias or a rewrite rule in an .htaccess file.
You only need to edit either .htaccess or httpd.conf, not both. If you have the choice, edit httpd.conf. Editing httpd.conf, which requires root access, is the preferred method because your wiki performs better.<ref name="technicalexplanation">Should you edit httpd or htaccess? Besides not requiring access to edit httpd.conf, the advantage of editing .htaccess is that all directories which are not mentioned in the RewriteRule for directories are not reachable from the outside anymore. However there is a performance penalty, as httpd then has to search up the directory tree and process all .htaccess files which may apply.</ref> Most shared hosting systems do not allow changes to httpd.conf.
- See the Apache article, When (not) to use .htaccess files.<ref name="apache">Until further notice, only Apache supports (out-of-box) rewrites such as Wikipedia's transforming ugly long URLs into simple short ones such as:
- http://localhost/index.php?title=Main_Page
transformed into:
- http://localhost/Main_Page.</ref>
Short URL "how to" miniguides
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.
|
In an attempt to find out which Short URL methods really work, after trying these methods please add either:
|
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 x17 Image:Face-sad.svgImage:Face-sad.svg
- Manual:Short URL/Page title -- Aliasing method--Root access Image:Face-sad.svgImage:Face-sad.svg
- Manual:Short URL/Page title -- Working method with mediawiki-1.11 Image:Smiley.svg x7 Image:Face-sad.svg Image:Face-sad.svg used this methodImage:Face-sad.svgImage:Face-sad.svg
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.svgImage:Face-sad.svg Image:Smiley.svg Image:Smiley.svgImage:Face-sad.svg
- Manual:Short URL/wiki/Page title -- no root access Image:Face-sad.svgImage:Face-sad.svgImage:Smiley.svgImage:Smiley.svgImage:Smiley.svgImage:Smiley.svgImage:Face-sad.svgImage:Smiley.svg
- Manual:Short URL/wiki/Page title -- Both no root and root access
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.svgImage:Smiley.svgImage:Smiley.svgImage:Smiley.svgImage:Smiley.svgImage:Smiley.svg
- Manual:Short URL/wiki/Page title -- with aliases--root access Image:Smiley.svgImage:Smiley.svg
- Manual:Short URL/wiki/Page title -- Apache rewrite--root accessImage:Smiley.svgImage:Smiley.svg
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
Wiki.example.com/Page_title
How to create: wiki.example.com/Page_title webpage addresses
- Manual:Short URL/wiki.example.com/Page_title--difficult
- Manual:Short URL/wiki.example.com/Page_title--Subdomain with no Subdirectory in Article URLImage:Smiley.svgImage:Smiley.svgImage:Face-sad.svg
- 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
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 ".<ref name="technicalexplantion2">Reason for the Ampersand problem: The reason for the Ampersand problem is that using the long form means that articles can't have ampersands in their name because they would be treated as query string separators and would never reach the PHP runtime environment. The cause of the is Ampersands problem is an old and problemic mod_rewrite bug. There are discussions of other possible solutions at lists.wikimedia.org and fgiasson.com.</ref>
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
- 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
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
Technical notes
<references/>
See also
- An explanation of what each Apache Rewrite rule does
- Explanation of what CGI modules are
- URL rewrite in IIS
- MediaWiki configuration settings Manual:$wgUsePathInfo Whether to use 'pretty' URLs











![[Main Page]](/modules/mediawiki/images/mediawiki.png)


