mrbrightside Posted September 8, 2006 Share Posted September 8, 2006 Im currently building a site for a university project, and im stuck with something.basically I have a users page were you can view a users profile. I pass the username to the page and the users details are loaded.for example.http://www.mywebsite.com/users/index.php?username=mrbrightsideso that all works. But I want to be a bit more professional with this and somehow hide the variable name. Ive seen it done on other website, but cant work out how or if it is possible to do using PHP. Basically how i want the URL to appear would be:http://www.mywebsite.com/users/mrbrightsideso the user name is passed, but you dont see the name of the page (index.php) nor the query string (?username=mrbrightside)is this possible? - if so how?thanks a million in advancestuart Quote Link to comment Share on other sites More sharing options...
Caesar Posted September 8, 2006 Share Posted September 8, 2006 Edit: ...after reading your question a second time. Quote Link to comment Share on other sites More sharing options...
448191 Posted September 8, 2006 Share Posted September 8, 2006 That is done in Apache, with mod_rewrite. You can't do it with php. Quote Link to comment Share on other sites More sharing options...
mrbrightside Posted September 8, 2006 Author Share Posted September 8, 2006 really? no way at all? darn! - oh well thanks anyway :'( Quote Link to comment Share on other sites More sharing options...
448191 Posted September 8, 2006 Share Posted September 8, 2006 Really. ;DIf your host supports it you could look into mod_rewrite. Drop them an email and read [url=http://www.workingwith.me.uk/articles/scripting/mod_rewrite]this[/url]. Quote Link to comment Share on other sites More sharing options...
mrbrightside Posted September 8, 2006 Author Share Posted September 8, 2006 ok well thanks for answering to my post so quickly anyway!I have played with .htaccess files before on another website i build, but this current one is hosted with godaddy.com, and I got a horrible feeling they dont allow you to mess with that kind of stuff.I will investigate anyway - thanks Quote Link to comment Share on other sites More sharing options...
jefkin Posted September 8, 2006 Share Posted September 8, 2006 Two other options for you mrbrightside,One, code all your variables in form elements and use $_POST['xyz'] to get them.Two, use sessions to hold your variables and use $_SESSION['xyz'] to get them.For either one, you'd want some sort of interface where you could set the variable, then store it by your chosen method, and display or whatever.Two can be tricky if you're unfamiliar with session variables.Jeff Quote Link to comment Share on other sites More sharing options...
mrbrightside Posted September 8, 2006 Author Share Posted September 8, 2006 thanks for your suggestionsim not too bad with sessions but dont really want too many of them flying about to hold variables like this. Im looking into the mod_rewrite solution as it seems exactly what I need to do, I just hope I can get it to work with godaddy.com Quote Link to comment Share on other sites More sharing options...
mrbrightside Posted September 8, 2006 Author Share Posted September 8, 2006 THANKYOU 448191A quick read through the link you suggested and a few attempts later and I got it all working! godaddy does support mod_rewrites!It didnt work when I tested if through the full subdomain path:e.g.http://beta.myurl.com/users/mrbrightsidebut did work through the full url:http://www.myurl.com/beta/users/mrbrightsidemaybe im doing something wrong in the .htaccess file, but at least it works!thanks againstuart 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.