• Is there any way to subtract a value from a parameter in an .htaccess file?

    I’m replacing an old cgi script with WordPress.
    Right now, I have something like this:

    RewriteCond %{QUERY_STRING} 4&([0-9]+)
    RewriteRule ^list\.cgi$ /noidea/index.php\?p=%1 [R]

    Now, this works fine to direct list.cgi?4&1 to /noidea/index.php?p=1.

    But, with my old script, I started at 0, and index.php?p=0 won’t work. So, I’m going to have to start my WordPress entries at 1, and then redirect list.cgi?4&0 to index.php?p=1 and list.cgi?4&1 to index.php?p=2 and so on.

    But I don’t know how to do arithmetic within .htaccess. How do I do so?

Viewing 2 replies - 1 through 2 (of 2 total)
  • I am a little confused-

    but can’t you just do a two part redirect- one which handles the cgi scripts that start with zero, and then your catchall that you already have, except start it at 1 instead of zero?

    Thread Starter RobotHero

    (@robothero)

    I suppose I could. Like, if I have 9 comics in there already, I’ll put the number 0 comic in post number 9. I’ll handle comics 1 through 8 as I already do, and have an extra rule for comic 0. Somehow that hadn’t occurred to me. I think I have a prejudice against exceptions.

    But I still would like to know how to do arithmetic. I’m sure it will come in handy some day.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘.htaccess and arithmetic’ is closed to new replies.