Please help! problem tackling a script to query db based on url

Discussion in 'PHP' started by gamesyphon, Dec 19, 2007.

  1. #1
    Hi,
    I have been trying a lot of different things to get around this problem: I have a url that looks like this: www.domain.com/name/index.php.... and I want to write a script that will pick the "name" part out of the url and then check that name against a database, lastly it will display information of that name from the database. Another tricky detail is that its not a fixed name, there will be hundreds of names with more added all the time so it needs to do a string search to grab the name.

    If anyone can even give me some links to code that will actually work for me (like how to get the FULL url) and so on that would be great.

    Any help is appreciated, thanks
     
    gamesyphon, Dec 19, 2007 IP
  2. akram

    akram Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi,

    Its called URL Rewriting.

    You need to setup .htaccess file in your / directory.

    sample content of the .htaccess for that purpose is:

    
    Options +FollowSymLinks
    RewriteEngine On
    RewriteRule ^([0-9]+)$ /$1/ [R]
    RewriteRule ^([0-9]+)/$ index.php?name=$1
    
    Code (markup):
    Let me know if your still not able to do it.

    Cheers!
     
    akram, Dec 19, 2007 IP
  3. gamesyphon

    gamesyphon Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ok thanks, so what would this actually do?

    my interpretation is that it will add the variable name with a value of $1 ??
    sorry, i don't quite understand.

    could you please explain what those 2 rules are doing?

    Thanks
     
    gamesyphon, Dec 19, 2007 IP
  4. sunnyverma1984

    sunnyverma1984 Well-Known Member

    Messages:
    342
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    120
    #4
    for more detail about url rewriting see this httpd.apache.org/docs/2.0/misc/rewriteguide.html
     
    sunnyverma1984, Dec 19, 2007 IP