sdlyr8 Posted June 24, 2009 Share Posted June 24, 2009 Hey, I've always wondered how its done. How does a page like www.domain.com/username know which user's profile to load? I know about GETs and POSTs, but how does one make a script like that? Basically the same deal with on wikipedia's site. Let me know if i'm not making any sense.. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/163563-wiki-like-url-get-variables-from-url/ Share on other sites More sharing options...
Alex Posted June 24, 2009 Share Posted June 24, 2009 If it just has http://domain.com/username besides using PHP to get the variable they're most likely using mod-rewrite to modify the URL. A normal url would look like http:/www.domain.com/somefile.php?variablename=value . Then in PHP to get that varaible you'd do: $variable = $_GET['variablename']; So in your example, www.domain.com/username, mod rewrite would be used and basically change the way the server sees that URL, most likely 'hiding' something like username=, allowing www.domain.com/?username=username to just be domain.com/username Quote Link to comment https://forums.phpfreaks.com/topic/163563-wiki-like-url-get-variables-from-url/#findComment-862969 Share on other sites More sharing options...
celsoendo Posted June 25, 2009 Share Posted June 25, 2009 Just to remember that mod_rewrite is not a php module. It's an Apache module: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html Quote Link to comment https://forums.phpfreaks.com/topic/163563-wiki-like-url-get-variables-from-url/#findComment-863057 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.