htaccess and problems passing variables in the URL.

Discussion in 'Programming' started by nico_swd, Dec 25, 2006.

  1. #1
    Hi,


    I have following htaccess file, and I'm getting a 404 error when I try to pass variables through the URL like this.

    url.com/search/?sort=hits

    While

    url.com/search/

    works. I tried adding ?%{QUERY_STRING} behind browse.php, but it didn't work.

    Any ideas?

    
    # DO NOT CHANGE THE FOLLOWING LINES
    # status: 1
    # pattern_category: {$cat_path}/more{$page}.html
    # pattern_detail: detail/{$link_id}/{$link_title}.html
    
    Options -MultiViews
    RewriteEngine On
    
    RewriteRule ^detail/(.*)/(.*)\.html detail.php?linkid=$1
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule ^.* browse.php
    
    Code (markup):
     
    nico_swd, Dec 25, 2006 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Bumpy bumpy.
     
    nico_swd, Dec 26, 2006 IP
  3. av1

    av1 Active Member

    Messages:
    168
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #3
    try this line:
    RewriteRule ^detail/([a-z0-9.-]+)$/([a-z0-9.-]+)$\.html detail.php?linkid=$1 [R=301,L]
     
    av1, Dec 26, 2006 IP
    nico_swd likes this.
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    Thanks, but the problem is somewhere in the other part.

    
    RewriteRule ^.* browse.php
    
    Code (markup):
    browse.php is being rewritten to "search", like in the example above. And I'm having problems to pass the variables to browse.php.
     
    nico_swd, Dec 26, 2006 IP
  5. pixel_perfect

    pixel_perfect Banned

    Messages:
    238
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    try this way!

     
    pixel_perfect, Dec 27, 2006 IP
    nico_swd likes this.
  6. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #6
    Still getting the same 404 error. This is how it looks now.

    
    Options -MultiViews
    RewriteEngine On
    
    RewriteRule ^detail/(.*)/(.*)\.html detail.php?linkid=$1
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ browse.php [L]
    
    Code (markup):
     
    nico_swd, Dec 27, 2006 IP
  7. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #7
    hopeless at reading descriptions,

    RewriteRule ^/search/(.*)/?$ /browse.php?sort=hits&search=$1

    or

    RewriteRule ^/search/(.*)/(.*)/?$ /browse.php?sort=$2&search=$1

    or possibly something totally different

    if u post an actual link to the page along with how you want the urls to look that'll sort it out .....
     
    krakjoe, Dec 27, 2006 IP
  8. pixel_perfect

    pixel_perfect Banned

    Messages:
    238
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    chang the

    "Options -MultiViews"

    to -> Options +FollowSymlinks

    and then try remove all the rules and try testing one by one,
     
    pixel_perfect, Dec 30, 2006 IP