gtal3x Posted February 26, 2008 Share Posted February 26, 2008 Hello, i understand how to pass variables throu pages and how to get the data that you need from them from sql database. What i dont understand is how to make this variable: somesite.com/users.php?username=John to work like that: somesite.com/users/John/ or even like: somesite.com/users/John.html I have seen this many times in different sites, but dont know how they do this, if you can explain to me or give me a link for an understandable tutorial i will appreciate it! Thanks Quote Link to comment Share on other sites More sharing options...
haku Posted February 26, 2008 Share Posted February 26, 2008 This isn't a php thing, its an .htaccess thing (part of apache servers. If you are using a windows server, I don't know how its done). Google mod rewrite, and there are tutorials and forums all about how to rewrite URLs (which is what you want to do). Quote Link to comment Share on other sites More sharing options...
blackwinter Posted February 26, 2008 Share Posted February 26, 2008 Well with this it isn't even php this has to do with your apache .htaccess files. There are ways to do this but I'll go with the easiest way... This is for apache httpd Create a file in your website main folder... the base folder called .htaccess Within the file, type the following RewriteEngine on RewriteRule ^/users/([^/\.])/?$ users.php?username=$1 this should help you out Quote Link to comment Share on other sites More sharing options...
gtal3x Posted February 26, 2008 Author Share Posted February 26, 2008 Thanks Quote Link to comment Share on other sites More sharing options...
blackwinter Posted February 26, 2008 Share Posted February 26, 2008 So it worked then ? Quote Link to comment Share on other sites More sharing options...
gtal3x Posted February 26, 2008 Author Share Posted February 26, 2008 So it worked then ? No because i dident try it. Basically I am starting a site now, and i wont to make the links look that way, the reason i posted this question was so i know, how should i write my links in the script, like you guys told me there is a mod_rewrite, or making a htaccess, so now i will make the site with normal links (if i understood right), and at the end just do the things you told me and it should work... Quote Link to comment Share on other sites More sharing options...
haku Posted February 26, 2008 Share Posted February 26, 2008 Thats the best way to do it. Quote Link to comment Share on other sites More sharing options...
blackwinter Posted February 26, 2008 Share Posted February 26, 2008 Yup, use the mod rewrite script i supplied and it should work if you have any problems just contact me. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.