Results 1 to 3 of 3
  1. #1

    mod_rewrite weirdness

    mod_rewrite is a great tool but the regex syntax is bizarre.

    Basically, I'm moving to a new site and I need to redirect users to new pages. If someone goes to: "index.php?name=Forums&file=viewtopic&t=854"
    I need to redirect them to "/bb/viewtopic.php?t=854"

    This is my code thus far:
    RewriteRule ^(.*)index.php\?(.*)$ /bb
    This is NOT WORKING! Obviously it's a bit bare, but if you go to "index.php?name=Forums&file=viewtopic&t=854"
    it does not get redirected. As soon as I remove that last question mark (and the backslash) it starts redirecting again... what am I doing wrong? Is there some weird way to escape question marks?
    Looking for a good drop down menu? Try WebDDM, the only flexible open source solution

  2. #2
    Join Date
    Jun 2004
    I don't remember the exact sentence for mod_rewrite but here's the regex to capture the numerical values for _GET['t']

    \\1 hold the number so you could use that for the redirecting.

    Hope it helps

  3. #3
    Your regexp in RewriteRule is invalid.
    To redirect from/bb/viewtopic.php?t=854 to index.php?name=Forums&file=viewtopic&t=854 use the following:

    RewriteRule ^/bb/viewtopic&t=([0-9]+)$ /index.php?name=Forums&file=viewtopic&t=$1 [L]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts