mod_rewrite question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • macaco
    New Member
    • Apr 2007
    • 9

    mod_rewrite question

    I'd like to redirect URLs in a directory in this way:

    categories/anything/index.php?id=13 to
    categories/index.php?id=13

    To achieve that, I've uploaded a .htaccess file to "categories " directory that contains the following:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^[.*]/index\.php\?id= ([0-9]*)$ index.php?id=$1
    </IfModule>

    But it keeps giving a 500 error

    How do I fix this?

    Many Thanks
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    What does the error log say?

    My guess is that it is the [.*] that is causing the problem. The asterisk should be outside the class, and seeing as there is only one character, the class isn't really needed.

    So I would try something like:
    Code:
    RewriteRule ^.*index\.php\?id=([0-9]*)$ index.php?id=$1

    Comment

    Working...