Jump to content
MakeWebGames

$_GET without full url help


Coly010

Recommended Posts

I was looking at Facebook and Twitter and noticed that when you view a user, in the address it bar it has say facebook.com/username

My question is can I do a similar thing with PHP, instead of having /viewuser.php?id=

I'm not exactly sure what to search for on google either, so if someone can give me a proper name for this then I can do a bit of digging

Link to comment
Share on other sites

You're looking for vanity URLs/pretty URLs - mod_rewrite.

An example would be something like;

 

RewriteEngine On
RewriteRule ^([^/]*)$ /viewuser.php?u=$1 [L,QSA]

 

However, that would direct everything to viewuser.php - but it's a start.

To accomplish what you're trying to achieve, look at RewriteCond (rewrite conditions)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...