How To: Migrating from php-nuke 6.0 to Xaraya 0.9.9

"Paul_C" <[email protected]> Sat, 8 May 2004 09:48:05 +0000 (UTC)
Newsgroups gmane.comp.cms.xaraya.knowledge-base
Organization Xaraya News Server
Message-ID <[email protected]>
I recently migrated a site from php-nuke 6.0 to Xaraya 0.9.9.
Aside from a facelift and some long-needed content
reorganization, it's just about done. Here's how I did it.

1. **Install Xaraya**

Following recommended procedure from the import_nuke script I:
1.1 installed Xaraya with the "Community Site" option
1.2 installed and activated the following modules:
    a. categories
    b. comments
    c. articles
    d. polls
    (hitcount and ratings are also represented, though I don't
    need them so I didn't install them.)
1.3 left the default privileges, hooks, and everything else
    alone... for now.


2. **Import the goods**

In the tests/import/phpnuke/ directory are some import scripts
to transfer users and content from php-nuke 6.5 to Xaraya. Some
minor adjustments were needed to make them work with php-nuke
6.0; I sent them to John so they should be coming soon to a
bitkeeper repo near you.

2.1 Copy all import_nuke*.php files to your Xaraya html/
    directory.
2.2 Copy the old php-nuke tables to your new Xaraya database
    (you can skip this if you installed Xaraya to the 
    same database as php-nuke.)
2.3 Go to your site http://www.example.com/import_nuke.php and
    follow the prompts.

Tada! You can stop here if this is all you need, but I wanted
to take advantage of Xaraya's short URLs and shorten them
further by getting rid of "/index.php".


3. **Short URLs**

Enable basic short URL functionality.

3.1 Under the Admin menu's "Global" heading choose "base" then
    "Modify Config". Place a check by "Enable Short URL Support"
    and submit the form.
3.2 Under the "Content" heading choose "articles" then "Modify
    Config" and make sure "Support short URLs" is checked.
    Repeat for whichever modules you like (where supported).


4. **Shorter URLs**

Stripping out the "index.php" to make them even shorter.
(NOTE:  Only tested using Apache 1.3; may likely work on Apache
2; I wouldn't bother trying with IIS. Mod_rewrite required.)

4.1 In the html/var/ directory is the file config.system.php.
    Open it in your favorite text editor. At the end of the file
    you should see two lines looking like this:

        //$systemConfiguration['BaseURI'] = '';
        //$systemConfiguration['BaseModURL'] = '';

    Uncomment them to make them look like this:

        $systemConfiguration['BaseURI'] = '';
        $systemConfiguration['BaseModURL'] = '';

4.2 Time for some mod_rewrite magic. There's ton of other
    content on this site besides that which lives in Xaraya, so
    we're checking to see if the requested URL would naturally
    point to something existing on the file system - if it
    doesn't the URL gets rewritten and the request sent to
    Xaraya.

    Create a file called .htaccess in Xaraya's html directory.
    Put in it the following:

        RewriteEngine on
        # Send anything we can't find to Xaraya
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.+) index.php/$1 [L]


5. **Dealing with old links**

This site got a good deal of traffic from search engine results
linking directly to the old php-nuke articles. I didn't want
these to die, so with a little more mod_rewrite magic we
permanently redirect them to the new locations.

Open up that .htaccess file again and just
after the "RewriteEngine on" line add the following:

# Redirect old php-nuke URLs
RewriteCond %{QUERY_STRING} ^name=News&file=article&sid=([0-9]+)
RewriteRule ^modules\.php$ /articles/%1? [R=301,L]

There's a handful of other php-nuke URL structures that this
isn't going to catch, but by far the majority of links will be
dealt with.


6. **Extras**

More .htaccess fun

6.1 I don't plan on distributing the site's theme, but
    unfortunately Apache will serve up all of Xaraya's template
    files as plain text by default. We prevent this with:

        # Protect files from prying eyes:
        <Files ~ "\.(xd|xt)$">
            order deny,allow
            deny from all
        </Files>

6.2 I'm a fan of xhtml so for URLs I change php's default
    argument separator to &amp; instead of &. In addition, I
    hate seeing session ids passed in the URL - they're a nasty
    security risk so I require cookies. Both of these are
    done with the following (requires mod_php4):

        # Overload PHP variables:
        <IfModule mod_php4.c>
            php_value arg_separator.output "&amp;"
            php_value session.use_trans_id "0"
        </IfModule>


7. **...**

...


8. **Profit!**



For copy & paste fun here's the completed .htaccess file:

# Protect files from prying eyes:
<Files ~ "\.(xd|xt)$">
    order deny,allow
    deny from all
</Files>

# Overload PHP variables:
<IfModule mod_php4.c>
    php_value arg_separator.output "&amp;"
    php_value session.use_trans_id "0"
</IfModule>

RewriteEngine on

# Redirect old php-nuke URLs
RewriteCond %{QUERY_STRING} ^name=News&file=article&sid=([0-9]+)
RewriteRule ^modules\.php$ /articles/%1? [R=301,L]

# Send anything we can't find to Xaraya
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+) index.php/$1 [L]


Comments, corrections, and additions are welcome.