Manual:Short URL/Allowing for escaped characters in URI

From MediaWiki.org
Jump to: navigation, search

[edit] Allowing for escaped characters in URI

It may happen that you only have access to the .htaccess file, and you would like to allow special characters such as + in the article title, and you are using Apache 2.x. LocalSettings.php therefore contains

[edit] ~/web_root/w/LocalSettings.php

$wgLegalTitleChars .= "+";

while .htaccess contains something like

[edit] ~/web_root/.htaccess

RewriteEngine on
RewriteBase /

RewriteRule ^wiki$ wiki/Main_Page [R,NC]
RewriteRule ^wiki/$ wiki/Main_Page [R,NC]

RewriteCond %{THE_REQUEST} ^[A-Z]+\ /wiki/([^?\ ]+)
RewriteRule ^wiki/(.+)$ /w/index.php?title=%1 [NE,L,QSA] 

The use of RewriteCond %{THE_REQUEST}... catches the query before Apache and PHP conspire to replace %2B in the URL with a space.

Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox