Php And .htaccess File Mod Url Rewrite Help

Discussion in 'PHP' started by xbat, Jan 24, 2013.

  1. #1
    Hello I am looking to build a mod rewrite and I got part of it working. But what Iran into was..

    I have this

    RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?id=$1
    Code (markup):
    Which will out put this
    mysite.com/14
    and display the info that id 14 sends through.

    How would I get my description to show up in the url too?

    I am echo description but I am still not getting anything..


    I am trying to get it to come out to mysite.com/14/description_stuff_stuff
     
    Solved! View solution.
    xbat, Jan 24, 2013 IP
  2. #2
    try this
    =============
    RewriteRule ^([a-zA-Z0-9_-]+)/(.*)$ index.php?id=$1
     
    dixcoder, Jan 24, 2013 IP
  3. xbat

    xbat Well-Known Member

    Messages:
    326
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    105
    #3
    Thank you that worked.. As for the description wouldn't someone be able to submit anything in there? Is there some way to some how make it required?
     
    xbat, Jan 25, 2013 IP
  4. xbat

    xbat Well-Known Member

    Messages:
    326
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    105
    #4
    Ok to better word this I have

    index.php?id=14&description=sfgsf

    It shows fine.. But then when I go the rewrite... No such luck

    Ok I figured out..

    I need something like this

    RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?id=$1&description=$2 [L]

    :) Thanks for at least pointing me in the right direction.
     
    Last edited: Jan 25, 2013
    xbat, Jan 25, 2013 IP