Manual:$wgActionPaths/pt-br

From Linux Web Expert

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
<translate> Server URLs and file paths</translate>: $wgActionPaths
Caminhos para várias ações do usuário. Usado para fazer URLs mais bonitas.
<translate> Introduced in version:</translate>1.5.0 (r7538)
<translate> Removed in version:</translate><translate> still in use</translate>
<translate> Allowed values:</translate><translate> Unspecified</translate>
<translate> Default value:</translate>[]

Detalhes

Setup Manual:Short URL and ensure it is working first

Para definir caminhos de URL "bonitos" para outras ações além de visualizações de página simples, adicionar a este array.

Por exemplo:

$wgActionPaths['edit'] = "$wgScriptPath/edit/$1";

Além de definir esta variável, você deve colocar em prática um script apropriado ou uma regra de reescrita de servidor para lidar com essas URLs.

Configurações de exemplo

Estes exemplos incluem amostras de arquivos .htaccess para servidores Apache usando mod_rewrite.

Outros servidores terão outras maneiras de realizar regravações de URL.

Caminhos de ações do diretório raiz

Esse item configura caminhos de ações do formulário http://mywiki.example.com/edit/Cucumber etc.

LocalSettings.php
$actions = [
	'view',
	'edit',
	'watch',
	'unwatch',
	'delete',
	'revert',
	'rollback',
	'protect',
	'unprotect',
	'markpatrolled',
	'render',
	'submit',
	'history',
	'purge',
	'info',
];

foreach ( $actions as $action ) {
  $wgActionPaths[$action] = "/$action/$1";
}
$wgArticlePath = $wgActionPaths['view'];

extra htaccess rules

.htaccess
Não se esqueça de modificar "/w/index.php" para onde você tem o MediaWiki instalado
RewriteRule ^/([a-z]*)/(.*)$ %{DOCUMENT_ROOT}/w/index.php [L,QSA]

action at the end

This sets up action paths of the form http://mywiki.example.com/Cucumber/edit etc.

$actions = [
	'edit',
	'watch',
	'unwatch',
	'delete',
	'revert',
	'rollback',
	'protect',
	'unprotect',
	'markpatrolled',
	'render',
	'submit',
	'history',
	'purge',
	'info',
];

foreach ( $actions as $action ) {
  $wgActionPaths[$action] = "/$1/$action";
}
$wgActionPaths['view'] = "/$1";
$wgArticlePath = $wgActionPaths['view'];

Non root action paths

For standard example.com/wiki/Main_Page rewrites to example.com/wiki/view/Main_Page use above config and change this line to include "/wiki":

foreach ( $actions as $action ) {
  $wgActionPaths[$action] = "/wiki/$action/$1";
}

For standard example.com/wiki/Main_Page view urls, and rewrites to example.com/wiki/edit/Main_Page

$actions = [
	'edit',
	'watch',
	'unwatch',
	'delete',
	'revert',
	'rollback',
	'protect',
	'unprotect',
	'markpatrolled',
	'render',
	'submit',
	'history',
	'purge',
	'info',
];

foreach ( $actions as $action ) {
  $wgActionPaths[$action] = "/wiki/$action/$1";
}
$wgActionPaths['view'] = "/wiki/$1";
$wgArticlePath = $wgActionPaths['view'];

action at the end

For standard example.com/wiki/Main_Page view urls, and rewrites to example.com/wiki/Main_Page/edit

you cannot have subpages of main pages named "delete, edit, watch, unwatch" etc from the array when setup like this.
$actions = [
	'view',
	'edit',
	'watch',
	'unwatch',
	'delete',
	'revert',
	'rollback',
	'protect',
	'unprotect',
	'markpatrolled',
	'render',
	'submit',
	'history',
	'purge',
	'info',
];

foreach ( $actions as $action ) {
  $wgActionPaths[$action] = "/wiki/$1/$action";
}
$wgActionPaths['view'] = "/wiki/$1";
$wgArticlePath = $wgActionPaths['view'];

Ações virtuais / diretórios

Esse item configura caminhos de ações do formulário http://mywiki.example.com/wiki/action/edit/Cucumber etc.

Para reescrever a maioria[1] das ações para um caminho específico, pode-se fazer as seguintes alterações em LocalSettings.php :

$actions = [
	'view',
	'edit',
	'watch',
	'unwatch',
	'delete',
	'revert',
	'rollback',
	'protect',
	'unprotect',
	'markpatrolled',
	'render',
	'submit',
	'history',
	'purge',
	'info',
];

foreach ( $actions as $action ) {
  $wgActionPaths[$action] = "$wgScriptPath/action/$action/$1";
}
$wgArticlePath = $wgActionPaths['view'];

No Apache, codifique uma regra de reescrita semelhante à seguinte:

RewriteRule ^/action/([a-z]*)/(.*)$ /index.php [L,QSA]

Esta ação encaminhará todas as solicitações para /action/actionword/title a index.php do MediaWiki que irá analisar a ação e título de acordo com suas configurações de $wgActionPaths.

Ao configurar o mod_negotation do Apache para executar scripts PHP ao usar esse método deve ser tomado cuidado para não causar erros 406 Não Aceitável, que podem, em alguns casos expor uma listagem de diretório, consulte [1], [2]. See also bugzilla:21617.

Prevenção de spams

Usar $wgActionPaths, especialmente para ações de edição, parece reduzir número de robôs de spam tentando editar artigos. Suspeita-se que os bots são programados para procurar action=edit para identificar uma instalação MediaWiki e agir de forma conveniente. Com isto em mente, seria benéfico nomear seu prefixo action com algo não tão aparente para que os bots não possam encontrar o seu site quando eles começarem a procurar action/edit.


  1. Actualmente, não é possível ter um $wgActionPath para a ação bruta.