Manual:Short URL/es

Short URLs or URL Rewrites hide php file extensions from the page address. 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 default direcciones de página parece estos ejemplos:
 * (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! see below)
 * (No recomendado! Ve abajo)
 * (not recommended! see below)
 * (No recomendado! Ve abajo)

Having the page name right in the root of the domain name is not recommended, because it will conflict with files and directories located at the root directory. For example, if you have your images in the /images/ directory, you wouldn't be able to access a page named "Images" in your wiki.

Advantages & disadvantages
MediaWiki parses paths directly from the REQUEST_URI so rewrite everything to /index.php.
 * Advantage: Short URLs hide some technical details from end-users, which can be desirable for site owners. Among other things, this means they can be kept stable when the underlying software changes. (See above for the difference between MediaWiki's default URL structure with CGI enabled vs without). They are also easier to read, remember, and manipulate for visitors. Additionally, short URLs offer an advantage over the default URLs for Search engine optimization, as URLs containing  can be treated less favorably by search engines when calculating page rank.    portion of rewrite rules like   which is completely unnecessary and harmful.

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
Our official guides for short url configuration include recommendations on how to point the root of your site to your wiki using your short url config.

For example our Apache guide recommends using this to point your site root to your wiki:

Note that we do not recommend doing a HTTP redirect to your wiki path or main page directly. As redirecting to the main page directly will hard-code variable parts of your wiki's page setup into your server config. And redirecting to the wiki path will result in two redirects. Simply rewrite the root path to MediaWiki and it will take care of the 301 redirect to the main page itself.

If using VirtualHosts, place the rewrite rules into the virtual host declaration!

Moving a wiki from /wiki to /w
A common beginner's mistake is to install MediaWiki itself (the source code, not the short url) in  instead of. Once installed they would realize the mistake when trying to configure Short URLs (which would become difficult as the virtual path then conflicts with the real path).

There is a manual for moving a wiki in general, however that is too complicated if all you need is to change the installation directory (and stay on the same server, same database and same hostname).

Here is what you have to do:


 * Backup  and any other config files you may have created (such as your  ).
 * Rename the installation directory of MediaWiki on your server from  to.
 * Set  in   to   and remove (or comment out) any definition of   (this variable will be changed again when setting up Short URLs, further on)
 * At this point your wiki should be working normally at
 * Now go through the regular guide to set up short URLs
 * Perform a few tests on your wiki to make sure nothing is broken. Edit a page, visit a few different pages, etc. If anything seems abnormal, revert the changes by restoring your backup of  and other relevant files you might have changed during configuration of short URLs and rename your folder back to.

Note for shared hosting users: Many shared hosting plans offer an application manager to automatically Install, Update and Backup applications such as MediaWiki. If your plan has this and if you want to keep using these features, you should contact their tech support and let them know you just manually changed your MediaWiki installation directory.