Mod_rewrite problem and my (not working) solution

Discussion in 'Apache' started by Kellerkind, Nov 6, 2006.

  1. #1
    I want to display the results of a wordpress plugin I wrote with search engine friendly urls.

    I tell this global categories mod via $_GET what posts of which category it should display. My first problem is that I can't get the rewrite to work.

    I want to rewrite:

    domain.com/categories/c=whatever
    to
    domain.com/categories/whatever


    This is the first standard part of my .htaccess

    RewriteEngine On
    RewriteBase /

    # Rewrite www.domain.com to domain.com
    RewriteCond %{HTTP_HOST} ^www\.(.*)
    RewriteRule ^(.*) http://%1/$1 [R,L]

    #uploaded files
    RewriteRule ^(.*)?/?files/(.*) wp-content/blogs.php?file=$2 [L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule . - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]

    #and here comes the rewrite rule that doesn't work
    RewriteRule ^categories/(.*)$ categories/?c=$1 [L]

    -------------------------


    Even if I could rewrite the url like this how could I get $_GET to work after the url is rewritten?

    Any help would be great!
     
    Kellerkind, Nov 6, 2006 IP
  2. WhiteHatHacker

    WhiteHatHacker Peon

    Messages:
    21
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Erm... not sure if I'm missing something here, or is the problem simply that the line

    RewriteRule . index.php [L]
    Code (markup):
    is catching everything and redirecting it to index.php before your new rule is reached? It doesn't seem to have any RewriteCond's attached...

    Good luck.

    EDIT: And as to your second query, what specifically do you mean? Doesn't
    $category = $_GET["c"]
    Code (markup):
    work?
     
    WhiteHatHacker, Nov 8, 2006 IP