Help: with my search friendly urls (.htaccess)

Discussion in 'PHP' started by calcalmx123, Feb 20, 2014.

  1. #1
    Hey, looking for a little help!
    I have only a basic knowledge in php and databases, enough to get me by and I dont know where to begin with .htaccess files. I have a basic script I've written and the website was offline for quite some time, now I have updated the script and got it back online I find my links don't work how they used to.

    It's a small arcade style website and I would like my urls to be formatted as domain.com/play/game-url-slug.php as they used to be, currently due to that format not working I am using domain.com/game.php?id=game-url-slug. inside the play folder is one file my .htaccess file containing the following:
    RewriteEngine On
    RewriteRule ^(.+)\.php$ /game.php?id=$ [NC]
    Code (markup):
    When I visit domain.com/play/game-url-slug.php i see the correct page (game.php) but with no values that should be retrieved from the database and echo'd such as the game, description ect.. The problem seems to be that the script doesn't see the ?id=url-slug there for doesn't load the appropriate data.
    Please can someone advise me of my problem,
    Many thanks, Callum.
     
    calcalmx123, Feb 20, 2014 IP
  2. DomainerHelper

    DomainerHelper Well-Known Member

    Messages:
    445
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    100
    #2
    RewriteRule ^play/(.*)/$ game.php?id=$1 [L,QSA]
    Code (markup):
    Btw, [NC] means "No Change".
     
    DomainerHelper, Feb 20, 2014 IP
    calcalmx123 likes this.
  3. calcalmx123

    calcalmx123 Well-Known Member

    Messages:
    1,498
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    195
    #3
    Managed to get this sorted now - thanks! :)
     
    calcalmx123, Feb 21, 2014 IP
  4. DomainerHelper

    DomainerHelper Well-Known Member

    Messages:
    445
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    100
    #4
    Anytime mate
     
    DomainerHelper, Feb 21, 2014 IP