301 Redirect with mod_rewrite and special characters

Discussion in 'Apache' started by danrinkes, Apr 19, 2010.

  1. #1
    Hi,

    I am an apache novice, but I've been given the task of making some redirects on a MediaWiki site that I manage. To give a short background, we had a number of URLs that were aliased to the same location, and now we're migrating to a single URL. So, I've been tasked with redirecting the existing URLs to the new "unified" one.

    In my .htaccess file, I have some entries like this

    RewriteCond %{HTTP_HOST} ^www.oldurl\.com$ [NC]
    RewriteRule ^(.*)$ http://www.newurl.com/$1 [R=301,L]

    As with most mediawikis, the format of the url is
    http;//www.oldurl.com/index.php?title=PageTitle

    My setup works in most cases, the /index.php?title=PageTitle gets appended to the new URL and everything works great.

    My problem occurs with mediawiki pages that have special punctuation in them, such as a question mark or an apostrophe.

    For example, a wiki page called
    Is_this_a_question?
    gets converted by mediawiki to be
    Is_this_a_question%3F

    The problem is that my redirect does not include the %3F. I've seen similar cases where an apostrophe gets converted to %2527.

    Can someone give me some direction as to how to modify my .htaccess file to handle these cases?

    Thanks,
    Dan
     
    danrinkes, Apr 19, 2010 IP