php pagination with mysql htaccess

Discussion in 'PHP' started by asgsoft, Mar 24, 2010.

  1. #1
    asgsoft, Mar 24, 2010 IP
  2. shockworks

    shockworks Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You are asking about .htaccess settings for page_number only, or for whole system (cat_name, sort,...)?
    Can you show here your actually .htaccess file?
     
    shockworks, Mar 24, 2010 IP
  3. asgsoft

    asgsoft Well-Known Member

    Messages:
    1,737
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    160
    #3
    I don't have a .htaccess file yet!

    and I would like the .htaccess settings for the whole system, i.e.cat_name, sort_by, page_number
     
    asgsoft, Mar 24, 2010 IP
  4. shockworks

    shockworks Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    RewriteRule ^/browse/(.+)/(.+)/(.*)$ /index.php?cat_name=$1&sort=$2&page=$3 [L]
     
    shockworks, Mar 24, 2010 IP
  5. asgsoft

    asgsoft Well-Known Member

    Messages:
    1,737
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    160
    #5
    aaah cool!

    I'll give that a try and see how it goes :)

    thanks in advance!
     
    asgsoft, Mar 24, 2010 IP
  6. asgsoft

    asgsoft Well-Known Member

    Messages:
    1,737
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    160
    #6
    I just tried that:

    Options +FollowSymLinks
    RewriteEngine On
    RewriteRule ^/browse/(.+)/(.+)/(.*)$ /index.php?cat_name=$1&sort=$2&page=$3 [L] 
    Code (markup):
    And I am getting a server 500 error.

    Any ideas?

    Edit:

    Actually it's all fine!!! Needed to enable to module on my server :)
     
    Last edited: Mar 24, 2010
    asgsoft, Mar 24, 2010 IP
  7. asgsoft

    asgsoft Well-Known Member

    Messages:
    1,737
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    160
    #7
    OK slight problem!!

    When I have this in my .htaccess file:

    RewriteRule ^/browse/eating-out/10/(.+)/(.*)$ /index.php?cat_id=10&sort=$1&page=$2 [L]
    Code (markup):
    and go to: http://www.site.com/browse/eating-out/10/

    I am getting a 404 error!

    Any ideas what's going wrong?
     
    asgsoft, Mar 25, 2010 IP
  8. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Change the rewrite rule back to how it was when shockworks wrote it. You don't need to add them manually for each category, it will do it itsself
     
    JAY6390, Mar 25, 2010 IP
  9. asgsoft

    asgsoft Well-Known Member

    Messages:
    1,737
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    160
    #9
    but the thing is, I need to show the category name in the URL for SEO purposes, then the ID would be for PHP purpose.

    So effectively im having to specify the category name and id in the rerwrite code to prevent any confusion, yet allow the page number and sorting method to be changed.

    Does that make sense?
     
    asgsoft, Mar 25, 2010 IP
  10. mnvlxxx

    mnvlxxx Peon

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Makes all sense :) That can be done with no problem.
     
    mnvlxxx, Mar 25, 2010 IP
  11. asgsoft

    asgsoft Well-Known Member

    Messages:
    1,737
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    160
    #11
    so how do I stop getting the 404 error then?
     
    asgsoft, Mar 25, 2010 IP
  12. mnvlxxx

    mnvlxxx Peon

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Maybe a missing slash (/).

    Please try this code:
    
    RewriteRule ^/browse/eating-out/10/(.*)/(.*)/$ /index.php?cat_id=10&sort=$1&page=$2
    
    Code (markup):
    Make sure the URL /index.php?cat_id=10&sort=xxxx&page=xxxx exists.
    Error 404 means "not found".
     
    mnvlxxx, Mar 25, 2010 IP
  13. asgsoft

    asgsoft Well-Known Member

    Messages:
    1,737
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    160
    #13
    I know what a 404 error is!!!!

    and no, adding a trailing slash doesn't work!!!
     
    asgsoft, Mar 26, 2010 IP
  14. asgsoft

    asgsoft Well-Known Member

    Messages:
    1,737
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    160
    #14
    asgsoft, Mar 26, 2010 IP
  15. shockworks

    shockworks Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Your problem: You are requiring "/" in URL: If you type site.com/browse/eating-out/10/// it is ok, isn't it?

    You have to define:
    RewriteRule ^/browse/eating-out/10/(.*)(/*)(.*)(/*)$ /index.php?cat_id=10&sort=$1&page=$3
     
    shockworks, Mar 28, 2010 IP
  16. asgsoft

    asgsoft Well-Known Member

    Messages:
    1,737
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    160
    #16
    RewriteRule ^/browse/eating-out/10/(.*)(/*)(.*)(/*)$ /index.php?cat_id=10&sort=$1&page=$3

    generates a 404 error.

    tbh I don't follow it either.
     
    asgsoft, Mar 28, 2010 IP