1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Couple of mod_rewrite qquestions

Discussion in 'Apache' started by al2six, May 12, 2005.

  1. #1
    I'm using a tutorial to do a mod_rewrite. Here is what it says to put in my htaccess file:

    RewriteRule ^products/([0-9][0-9])$ products/$1/ [R]
    RewriteRule ^products/([0-9][0-9])/$ productinfo.php?prodID=$1

    According to the tut, the "[R]" signifies that the viewer should be aware of the redirect (it should change the address in their browser's addy bar). However, when I use the code above, I get 404s. When I take the [R] out, it redirects to the correct page, but doesn't change the address in the address bar.

    anyone know whats wrong?


    Also, I have product IDs with spaces in them. So I tried to make the range in the htaccess file include % (%20 for the space) but it isn't working.

    any help?

    thanks!
     
    al2six, May 12, 2005 IP
  2. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #2
    I'm no expert, but I would write it this way and try it.

    RewriteEngine on
    RewriteBase /YOUR-FOLDER
    RewriteRule ^products/([0-9][0-9])/$ productinfo.php?prodID=$1
     
    noppid, May 12, 2005 IP
  3. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #3
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^products/(.*)/$ productinfo.php?prodID=$1 [L]
     
    Nintendo, May 12, 2005 IP
  4. al2six

    al2six Active Member

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #4
    Thanks nintendo! Now can anyone help me make it so that if you don't add the trailing slash it will still work?

    I tried this, but it gives 500 errors:


    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^products/(.*)$ products/$1/ [L]
    RewriteRule ^products/(.*)/$ productinfo.php?prodID=$1 [L]
     
    al2six, May 12, 2005 IP
  5. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #5
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^products/(.*)/$ productinfo.php?prodID=$1 [L]
    RewriteRule ^products/(.*)$ productinfo.php?prodID=$1 [L]

    Both with and with out the last / should work.
     
    Nintendo, May 12, 2005 IP