Question

I need help with URL rewriting.

I have given up on mediawiki due to all spam bots. I managed to convert all articles to dokuwiki and is now stuck on redirecting old links.

The article title is

Namespace:category/page

The old link is

http://www.mediawikilink.com/?title=Namespace%3Acategory%2Fpage

The new link is

http://www.dokuwikilink.com/?id=Namespace%3Acategory%2Fpage

I tried the following .htaccess rule:

RewriteCond %{QUERY_STRING} title=([^&]+)
RewriteRule ^(.*)$ /$1?id=%1 [R=301,L]

Ending up with a bad result:

doku.php?id=Namespace%253Acategory%252Fpage
URL decoded: Namespace_3a_category_2f_page

I believe the problem lies within RewriteCond parsing raw non-decoded values and RewriteRule encodes it over again.

Was it helpful?

Solution

Is this better ?

RewriteCond %{QUERY_STRING} title=([^&]+)
RewriteRule ^(.*)$ http://www.dokuwikilink.com$1?id=%1? [NE,R=301,L]

NE: noescape.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top