2

I have tried many ways, but without successful result.

Target wiki access url: www.example.com/wiki/Ampersand_%26_nextampersand_%26_plus_%2B_nextplus_%2B_text

Apache internally process the %26 and %2B as & and + so we need to convert it again to url style. (as mentioned here www.mediawiki.org/wiki/Manual_talk:Short_URL/Ampersand_solution#Another_solution)

Following example handles only 1 appearance of & or +, not combined.

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^wiki/(.*)\&(.*)$ w/index.php?title=$1\%26$2
RewriteRule ^wiki/(.*)\+(.*)$ w/index.php?title=$1\%2B$2
RewriteRule ^wiki/(.*)$ /w/index.php?title=$1 [PT,L,QSA]
RewriteRule ^/?wiki/*$ /w/index.php [L,QSA]
RewriteRule ^/*$ /w/index.php [L,QSA]

The question is how to get all & and + signs replaced by %26 and %2B and finally forwarded to processing index.php.

I have tried approaches like

RewriteRule ^([^+]*)\+(.*) $1%2B$2 [N] #freezes
RewriteRule ^wiki/([^+]*)\+(.*) wiki/$1%2B$2 [N] #freezes

and many others (in combinations) from following advices, but I couldn't find working solution.

Apache Mod Rewrite - Replace : character with another

mod_rewrite: replace underscores with dashes

definitely there is a solution as Wikipedia is using some successful way how to do it.

http://en.wikipedia.org/wiki/%26_Yet_%26_Yet

http://en.wikipedia.org/wiki/C%2B%2B

Any ideas? Thank you.

Community
  • 1
  • 1

1 Answers1

0

It seeems that I needed some rest time and fresh search so finally I can answer my own question.

solution was hidden here:

http://www.mediawiki.org/wiki/Manual:Short_URL/Allowing_for_escaped_characters_in_URI

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]