I need you! Small php problem

Discussion in 'PHP' started by Nilgesz, Mar 16, 2008.

  1. #1
    Nilgesz, Mar 16, 2008 IP
  2. pwaring

    pwaring Well-Known Member

    Messages:
    846
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    135
    #2
    Are you sure that's a PHP problem? Looks more like an issue with Apache rewrite rules to me.
     
    pwaring, Mar 16, 2008 IP
    Nilgesz likes this.
  3. DimitarMK

    DimitarMK Peon

    Messages:
    42
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Post your .htaccess file, so we can help you. I don't think this is PHP Problem, as pwaring said.
     
    DimitarMK, Mar 16, 2008 IP
    Nilgesz likes this.
  4. Nilgesz

    Nilgesz Well-Known Member

    Messages:
    2,039
    Likes Received:
    139
    Best Answers:
    0
    Trophy Points:
    160
    #4
    Thanks for fast replies!

    RewriteEngine On
    RewriteBase /
    RewriteRule ^([^/]*)/([/]*)$ /cities.php?cid=$1
    RewriteRule ^(.+-bowling-alleys)/([^/]*)$ /listings.php?cid=$1&uid=$2
    RewriteRule ^(.+-bowling-alleys)/(.+)/(.+)$ /business.php?cid=$1&uid=$2&wid=$3

    This is the htaccess file.
     
    Nilgesz, Mar 16, 2008 IP
  5. rob215

    rob215 Well-Known Member

    Messages:
    170
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    #5
    I would add this line to your .htaccess file

    RewriteRule ^(.+-bowling-alleys)$ /listings.php?cid=$1

    That should fix it. If not pm me I'll help you get it fixed
     
    rob215, Mar 16, 2008 IP
  6. Nilgesz

    Nilgesz Well-Known Member

    Messages:
    2,039
    Likes Received:
    139
    Best Answers:
    0
    Trophy Points:
    160
    #6
    Nilgesz, Mar 17, 2008 IP
  7. rob215

    rob215 Well-Known Member

    Messages:
    170
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    #7
    Ok what is happening is the trailing slash is needed for the php script.

    So here is another suggestion.

    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^(.+[^/])$ $1/ [R]

    So your htaccess file would look like this

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^(.+[^/])$ $1/ [R]
    RewriteRule ^([^/]*)/([/]*)$ /cities.php?cid=$1
    RewriteRule ^(.+-bowling-alleys)/([^/]*)$ /listings.php?cid=$1&uid=$2
    RewriteRule ^(.+-bowling-alleys)/(.+)/(.+)$ /business.php?cid=$1&uid=$2&wid=$3

    Notice the new RewriteCond line. That will check to see if there is a trailing slash and then the next line will add one if the / is not there.

    You can view this apache doc page.
    http://httpd.apache.org/docs/1.3/misc/rewriteguide.html
    Hope this time we've helped to clear up this problem for you.
     
    rob215, Mar 17, 2008 IP
    Nilgesz likes this.
  8. Nilgesz

    Nilgesz Well-Known Member

    Messages:
    2,039
    Likes Received:
    139
    Best Answers:
    0
    Trophy Points:
    160
    #8
    It's not working. Added you on MSN hope we can resolve this! and thanks for your time Robert
     
    Nilgesz, Mar 17, 2008 IP