[pmwiki-users] Mediawiki to PmWiki migration - how to preserve old links

Andrew Fyfe andrew at neptune-one.net
Fri Jan 12 18:40:36 CST 2007



Patrick R. Michaud wrote:
> On Fri, Jan 12, 2007 at 10:39:06PM -0000, Crisp, Steve [UK] wrote:
>   
>>    All,
>>     
>>    You (Patrick) came up with the goods with my last problem (ref. redirect
>>    to URL), here's another....
>>     
>>    I'm migrating this OpenSource site from MediWiki to a proper Wiki - PmWiki
>>    of course!  I need to preserve links to around 50 articles (read:
>>    URLs) and have them redirected to the relevant (new) PmWiki articles. 
>>    Example below:
>>     
>>    Existing MediaWiki URL:
>>    http://wiki.enginuity.org/index.php?title=Frequently_Asked_Questions
>>     
>>    New PmWiki URL (temporary site!):
>>    http://scoobypedia.co.uk/enginuity/index.php/Enginuity/FrequentlyAskedQuestions
>>     
>>    I want to retire the 'old' wiki so running it parallel is a last resort.
>>     
>>    Has this problem already been solved before?  Do you recommend it's solved
>>    in PmWiki or in some kind of web server configuration?
>>     
>
> I'd do it with a special-purpose php script.
>
> As a start, you could replace your existing (MediaWiki) index.php
> script with something like the following:
>
>     <?php
>       $title = @$_REQUEST['title'];
>       header("Location: http://scoobypedia.co.uk/enginuity/index.php/Enginuity/$title");
>
> This would cause all requests to the old MediaWiki pages to
> result in a redirect to the new PmWiki location.
>
> Then we just need to figure out if there are any name-remappings
> required, since MediaWiki uses underscores between words while
> PmWiki uses CamelCase.  A simple "remove all the underscores"
> approach would be:
>
>     <?php
>       $title = @$_REQUEST['title'];
>       $title = str_replace('_', '', $title);
>       header("Location: http://scoobypedia.co.uk/enginuity/index.php/Enginuity/$title");
>
> Other modifications can be added with little difficulty (I'll be glad
> to help with this).
>
> Pm
>
> _______________________________________________
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
> http://www.pmichaud.com/mailman/listinfo/pmwiki-users
>   
You should also send the proper HTTP response header, it won't make much 
difference for normal users, but for search engines will now that the 
new location is the same page (keeping it's page rank) rather than 
reindexing it as a new page (starting with a 0 page rank).

If the location is permanent use:
    header('HTTP/1.1 301 Moved Permanently');
or if it's only a tempory location use:
    header('HTTP/1.1 307 Temporary Redirect');


Andrew




More information about the pmwiki-users mailing list