Manual:Short URL/pt
URLs Curtos ou Reescrever URL oculte as extensões de ficheiro php no endereço da página. Por favor, reserve alguns minutos para criar uma estrutura de URL estável para o seu site da Web antes de começar, para reduzir os problemas mais tarde.
Introdução
Objetivo
O caminho de instalação predefinido do MediaWiki geralmente parece-se com isto:
/var/www/html/mediawiki
(instalado como utilizador raiz)/home/johndoe/public_html/mediawiki
(instalado com um provedor de alojamento partilhado)
Os endereços da página predefinida do MediaWiki, parecem-se com estes exemplos:
https://example.org/w/index.php/Page_title
(versões recentes do MediaWiki, sem suporte para CGI)https://example.org/w/index.php?title=Page_title
(versões recentes do MediaWiki, com suporte para CGI)
Utilizando os métodos descritos nesta página, nós podemos configurar algo como isto:
https://example.org/wiki/Page_title
Esta é a configuração mais comum, como na Wikipédia, embora não seja a predefinição porque esta requer modificações no lado do servidorhttps://example.org/view/Page_title
https://wiki.example.org/view/Page_title
https://example.org/Page_title
https://wiki.example.org/Page_title
Algumas pessoas não recomendam as duas últimas configurações. Consulte Manual:Wiki in site root directory para encontrar possíveis problemas e soluções.
Vantagens e desvantagens
- Vantagens: URLs Curtos ocultam alguns detalhes técnicos do utilizador final, que pode ser desejável para os donos do site. Entre outras coisas, isto significa que eles podem ser mantidos estáveis quando o programa subjacente é alterado. (Veja em cima a diferença entre a estrutura predefinida do URL da MediaWiki com a CGI ativada ou não ativada.) Eles também são mais fáceis de ler, lembrar, e manipular para os visitantes. Além disso, os URLs curtos oferecem uma vantagem sobre os URLs predefinidos para SEO porque os URLs com
?
podem ser tratados menos favoravelmente para os mecanismos de pesquisa quando calculam a classificação da página.
- Disadvantage: Requires configuration, so, depending on the hosting environment you are using, it might be difficult to recreate.
However, as every widely used webserver is capable of being configured to use short URLs, most paid web hosting services should support this feature. Any host that doesn't offer you this feature is not worth your money.
Guias
Our official guides for short URL configuration for different web servers. Pick your web server's configuration from this list. If you don't know what server software you are using, then it is most likely Apache.
Outros míni guias para "Como fazer..."
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.
URL como - exemplo.com/wiki/Titulo_da_pagina
Acesso de raiz
These methods require that you have access to the server configuration. If you are on a shared host, you most likely don't. In this case you will be required to use a method that requires "no root access". You can jump directly to the MediaWiki ShortURL Builder tool and follow the on-screen instructions. Select "I don't have root access" after entering your wiki's URL.
- wiki/Page title -- Lighttpd rewrite--root access
x4
- wiki/Page title -- Cherokee rewrite--root access
x1
- IIS8.5
x2
x1
- Abyss
(for Apache guidance, see the link in the Guides section).
URL como - exemplo.com/Titulo_da_pagina
How to create example.com/Page_title
URLs:
- Page title - nginx, Root Access, PHP as a CGI module
x6
- Page title -- Windows & Apache without 403 on Special Pages
x3
URL como - wiki.exemplo.com/Titulo_da_pagina
Como criar os URLs wiki.exemplo.com/Título_da_pagina
:
Resolução de Problemas
Ampersand (e) problema
The ampersand problem shows up when you have page titles with symbols in them (such as &, ?, #, +, /) which, 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. For example, clicking on a link to "John & Maria's page" gets a 404, because MediaWiki is looking for a page named "John ".
This is because ampersands in long-form names are treated as query string separators, and would never reach the PHP runtime environment. This is caused by an old and problematic mod_rewrite bug.[1]
Solução:
This issue is caused by the ?title=$1
portion of rewrite rules like /index.php?title=$1
which is completely unnecessary and harmful.
MediaWiki parses paths directly from the REQUEST_URI, so rewrite everything to /index.php.
Limpar cache
If you notice that your changes to $wgArticlePath
in LocalSettings.php
are not being reflected in example.com/wiki/Main_Page
, it may be due to MediaWiki's caching of the links according to previous settings.
Go to example.com/wiki/Main_Page?action=purge
to force MediaWiki to regenerate the cached links.
Também pode:
- Execute a consulta de MySQL "TRUNCATE objectcache;", ou
- Certifique-se que
$wgCacheEpoch
está atualizado (se$wgInvalidateCacheOnLocalSettingsChange
está ativado, tudo o que tem de fazer é editar LocalSettings.php para o purgar)
Redirecionar o visitante do seu domínio para a sua 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:
RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]
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!
Mover uma wiki de /wiki para /w
A common beginner's mistake is to install MediaWiki itself (the source code, not the short URL) in /wiki
instead of /w
.
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).
Aqui tem o que fazer:
- Backup
LocalSettings.php
and any other config files you may have created (such as your.htaccess
).
- Rename the installation directory of MediaWiki on your server from
/wiki
to/w
.
- Set
$wgScriptPath
inLocalSettings.php
to"/w"
and remove (or comment out) any definition of$wgArticlePath
(this variable will be changed again when setting up Short URLs, further on)
- At this point your wiki should be working normally at
example.org/w
- 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 LocalSettings.php
and other relevant files you might have changed during configuration of short URLs and rename your folder back to /wiki
.
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.
Truques
Consultar também
- $wgUsePathInfo - configuration setting that defines whether to use 'pretty' URLs or not
- $wgActionPaths - configuration setting that you can use to define 'pretty' URLs for other actions, like edit or history
- Clean up URLs RFC - proposes "cleaner URLs for editing, previewing skins, etc."
Hiperligações externas
- Módulo Apache mod_rewrite - reescreve URLs solicitados rapidamente
- Ferramenta de Criação de URL Curto na MediaWiki - "Uma ferramenta que pode gerar automaticamente uma configuração de url curto de forma mais fiável do que as configurações nestas páginas do manual.
- URL como IU por Jakob Nielsen sobre a importância dos URLs persistentes e utilizáveis.
Referências
- ↑ Bugzilla mod_rewrite for ampersand bug, partially resolved for some users, but only after 13 years