htaccess重写网址

Hi can anyone help me i want to rewrite some bad php urls in htaccess I have urls on my site which looks like this: http://www.spellentuin.nl/puzzel-spellen.php?pag=2&order= and so on for every following page they must show up like this: http://www.spellentuin.nl/puzzel-spellen2.php (order= must dissapear and next page must be puzzel-spellen3.php and so on) What do i need to put in htaccess to get this done and do i need to put same code for every page i have because i have a lot of different game category pages? At this moment google does not index any of those following pages. If you have better ideas than puzzel-spellen2.php please suggest also.

Many thanks for help!

The rewrite rule is pretty straight forward (if you just have this case)

RewriteEngine on
RewriteRule ^puzzel-spellen([0-9]+).php$ /puzzel-spellen.php?pag=$1&order=

In order to use this, you have also to modify every link. This could be done by register an output filter like so (this has to be placed at the very beginning of your scripts - before you output anything)

ob_start(function($str) {
    return preg_replace(
        '/\/puzzel-spellen\.php\?pag=([0-9]+)&order=/',
        'puzzel-spellen$1.php',
        $str);
});

But the better solution would be to modify every link. I.e.

'<a href="puzzel-spellen.php?pag=' . $i . '&amp;order=' . urlencode($_GET['order'])

just becomes (as you dont want order to be included)

'<a href="puzzel-spellen' . $i . '.php'