htaccess mod_rewrite help

Discussion in 'PHP' started by turulojko, Mar 20, 2008.

  1. #1
    hi,
    i need some help with .htaccess

    i want urls like:
    www.bla.com/gallery.php?what=disco&place=kiss&date=12112007&pic=3

    to be shown like:
    www.bla.com/gallery/disco/kiss/12112007/3/

    i use
    RewriteRule ^gallery/(.*)/ gallery.php?what=$1
    RewriteRule ^gallery/(.*)/(.*)/ gallery.php?what=$1&place=$2
    ...

    but this only works when your url is www.bla.com/gallery/disco/
    when your url is www.bla.com/gallery/disco/kiss/ (...) doesn't work.

    so, can someone help me somehow?
    thanks!
     
    turulojko, Mar 20, 2008 IP
  2. AsHinE

    AsHinE Well-Known Member

    Messages:
    240
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    138
    #2
    Try changing
    RewriteRule ^gallery/(.*)/(.*)/ gallery.php?what=$1&place=$2
    to
    RewriteRule ^gallery/(.+?)/(.+?)/ gallery.php?what=$1&place=$2
     
    AsHinE, Mar 21, 2008 IP
  3. turulojko

    turulojko Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    That shows me Internal Server Error.
     
    turulojko, Mar 21, 2008 IP
  4. bpasc95

    bpasc95 Active Member

    Messages:
    196
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    70
    #4
    This this one:

    RewriteEngine On
    RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)\.html$ /gallery.php?what=$1&place=$2&date=$3&pic=$4 [L]

    It doesn't have the word gallery in the URL, but it's a start.
     
    bpasc95, Mar 21, 2008 IP
  5. turulojko

    turulojko Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Shows me Error 404. :confused:
     
    turulojko, Mar 21, 2008 IP