mod_rewrite()

Discussion in 'Apache' started by lixor, May 18, 2005.

  1. #1
    hi

    i read the other thread about mod_rewrite(), on this forum, but i'm still trying to modify it for me, and no result.

    so when i have:
    ../phones.php i want to be transformed in ../phones
    ../phones.php?mn=motorola -> ../phones/motorola
    ../phones.php?mn=motorola&pn=v3 -> ../phones/motorola/v3

    haw do i make this? which is the .htaccess for this example?

    thanks
     
    lixor, May 18, 2005 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^phones/(.*)/(.*)$ phones.php?mn=$1&pn=$2 [L]
    RewriteRule ^phones/(.*)$ phones.php?mn=$1 [L]
    RewriteRule ^phones$ phones.php [L]
     
    Nintendo, May 18, 2005 IP
  3. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #3
    where or how did you learn this, Nintendo?
     
    fryman, May 18, 2005 IP
  4. iktorn

    iktorn Peon

    Messages:
    66
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    reading manuals?
     
    iktorn, May 18, 2005 IP
  5. WhatiFind

    WhatiFind offline

    Messages:
    1,789
    Likes Received:
    257
    Best Answers:
    0
    Trophy Points:
    180
    #5
    WhatiFind, May 18, 2005 IP
  6. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #6
    Wow... looks like I have a lot of reading to do... :D
     
    fryman, May 18, 2005 IP
  7. ashiezai

    ashiezai Peon

    Messages:
    927
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #7
    nintendo is a mod_rewrite expert .. check out the aws mod_rewrite hack. awesome :)
     
    ashiezai, May 18, 2005 IP
  8. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #8
    It started on Amazons associate board when I first tried to make a mod_rewrite version of MrRats COOL AWS script. I made a post asking how to change a few URLs, just like this thread. I made a few changes to the code and then it worked!!

    Now every one over at the Amazon Associate boards hate me, and I hate myself, because I generated a TON of competition for Amazon stores, I got over 150 paid users, generating competition (Yes, they got unlimated updates. :(). Luckly I got over 1,000,000 AWS URLs indexed in Google right now!

    Before the hack was used by a lot of users, I had a $7,500 Q4 quarter. Now I'm lucky if Q4 is $1,000. Moral of the story, if you find an easy way to get rich quick, SHUT UP ABOUT IT!!!!! :(
     
    Nintendo, May 18, 2005 IP
  9. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #9
    RewriteRule cannot have query strings in the pattern. You need to use something like this (assuming that you want to redirect):

    RewriteCond %{QUERY_STRING} ^mn=([^&]+)&pn=([^&]+)$
    RewriteRule ^\.\./phones\.php$ ../phones/%1/%2? [R=301,L]

    J.D.
     
    J.D., May 19, 2005 IP