How to do permalink

Discussion in 'PHP' started by TheSyndicate, Apr 16, 2009.

  1. #1
    I have a problem on my lawyer search page.

    i want

    http://local-lawyer-directory.com/info.php?id=12
    PHP:
    to look more like

    http://local-lawyer-directory.com/country-name of law company
    PHP:
     
    TheSyndicate, Apr 16, 2009 IP
  2. nayes84

    nayes84 Member

    Messages:
    34
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #2
    you need to make htaccess file to pass permalink to real php file
    like
    RewriteEngine On
    RewriteRule ^country-(.*)\$ info.php?id=$1 [L]

    for more information about htaccess file check
    http://httpd.apache.org/docs/1.3/howto/htaccess.html
     
    nayes84, Apr 17, 2009 IP
  3. atlantaazfinest

    atlantaazfinest Peon

    Messages:
    389
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    To make it work by name of law company you will have to edit the php file to read from the DB using name not the id number.
     
    atlantaazfinest, Apr 17, 2009 IP
  4. TheSyndicate

    TheSyndicate Prominent Member

    Messages:
    5,410
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    365
    #4
    Now i get two diffrent answers who got the real answer?
     
    TheSyndicate, Apr 17, 2009 IP
  5. jorgy

    jorgy Peon

    Messages:
    611
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Both solution will work, but in a different way.

    Changing the htaccess will allow you to have links that look like:
    http://local-lawyer-directory.com/country-name of law company

    The second solution given would look like:
    http://local-lawyer-directory.com/info.php?name=country-name of law company

    Both valid solutions, the first one's maybe a little prettier, and the second a little easier to accomplish.

    Hope that helps!
     
    jorgy, Apr 18, 2009 IP
  6. TheSyndicate

    TheSyndicate Prominent Member

    Messages:
    5,410
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    365
    #6
    htaccess since i am a noob on htaccess is that correct? Should i use the one in the root folder to make this happen?
     
    TheSyndicate, Apr 18, 2009 IP
  7. jorgy

    jorgy Peon

    Messages:
    611
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Not a real htaccess expert either.. but http://codex.wordpress.org/Using_Permalinks might shed some light on the issue. The article's about how wordpress uses this trick... but goes into pretty good detail. A google search should help you find some more info. Good luck!
     
    jorgy, Apr 18, 2009 IP
  8. TheSyndicate

    TheSyndicate Prominent Member

    Messages:
    5,410
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    365
    #8
    If some one can give me the correct code i am willing to pay give $5 so i do not have to guess :)
     
    TheSyndicate, Apr 18, 2009 IP
  9. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #9
    Well You Can Use this .htaccess code

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule country-name/$ /info.php?id=12
    Code (markup):
    Change the country-name part as per ur needs
     
    Bohra, Apr 18, 2009 IP
  10. anisbd

    anisbd Active Member

    Messages:
    204
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    83
    #10
    You Can Use this .htaccess code
     
    anisbd, Apr 18, 2009 IP
  11. TheSyndicate

    TheSyndicate Prominent Member

    Messages:
    5,410
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    365
    #11
    well so i need to add one for each country? since i have all countries?
     
    TheSyndicate, Apr 18, 2009 IP
  12. anisbd

    anisbd Active Member

    Messages:
    204
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    83
    #12
    yes ... you can try.. this process
     
    anisbd, Apr 19, 2009 IP
  13. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #13
    Yes un less u have individual countries in ur databese then i think it possible to do it automatically
     
    Bohra, Apr 19, 2009 IP
  14. TheSyndicate

    TheSyndicate Prominent Member

    Messages:
    5,410
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    365
    #14
    un less u have individual countries ?
     
    TheSyndicate, Apr 20, 2009 IP
  15. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #15
    Can u tell me how is ur databese structure from where the country name is pulled out
     
    Bohra, Apr 20, 2009 IP