.htaccess - creating nice looking URLs -


i trying make friendly looking urls ugly urls.

mod directory contains index.php , user.php file. index.php has links, of various formats, user page.

path mod directory : http://localhost/mod/

at time user's urls this..

http://localhost/mod/user.php?id=ricky etc..

i need make ugly 1 nice looking 1 this..

http://localhost/mod/user/ricky

i tried in htaccess file, , code far in file.

# enable rewriting rewriteengine on  # rewrite user urls #   input:  user/name/ #   output: user.php?id=name rewriterule ^user/([a-z]+)/?$ user.php?id=$1  

this not working me. hope me. thank you.

rewriterule ^user/([a-za-z]+)/?$ user.php?id=$1 [nc,l] 

state end of line , case insensitive [nc,l]

you can use \w match text chars (non digit)

rewriterule ^user/(\w+)/?$ user.php?id=$1 [nc,l] 

here's cheat sheet regex: http://www.regular-expressions.info/reference.html


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -