Can I make all the links lowercase using MediaWiki and use a hyphen instead of an underscore as a word delimiter?

Can I make MediaWiki links lowercase and use hyphens instead of underscores as word separators?

Regarding what WordPress or other CMSes do wiki .

+3
source share
4 answers

In MediaWiki, you can use hyphens instead of underscores to indicate spaces. wikiHow does this. But the source code requires a number of fixes, which is usually not recommended. In addition, there is no guarantee that there would be no errors.

+1

, , , , URL- / .

, , - . , , :

For examples of this see [[making-mediawiki-links-lowercase|making mediawiki links lowercase]].

wikilink ; (, , ).

href . LocalSettings.php:

$wgCapitalLinks = False; # like mentioned above: make MW not capitalize the page titles
$wgHooks['LinkEnd'][] = "seoUrls"; # add a hook to rewrite the links
function seoUrls($dummy, Title $target, array $options, &$html, array &$attribs, &$ret) {
    $attribs = str_replace("_", "-", $attribs);
    return True;
}

href , , , .

CSS, ( ) . CSS :

.ns-0.action-view #firstHeading, /* main */
.ns-14.action-view #firstHeading /* categories */
{
    display: none
}

- , , . , 0 () 14 ().

, , Mediawiki, , h1 .

, URL-, - :

RewriteRule ^([^_]*)_([^_]*_.*) $1-$2 [N]
RewriteRule ^([^_]*)_([^_]*)$ /$1-$2 [L,R=301]

  • , , , , . , , .
  • , , .
  • -; - h1.

  • . , , ": ".
  • mediawiki- -ASCII- URL-.
+2

, . . .

0

, : Template:Lowercase. {{Lowercase}} , .

- - ​​ .

0

Source: https://habr.com/ru/post/1737697/


All Articles