Covering up ?<get>=$ With any text

Hi my name is Aidan and I am new here.

Me and my friends are making a Social Network just for fun and to help us learn PHP in a more fun way. We are wanting to know if there is way to cover up the GET in the URL bar.

For example when your visiting a user’s profile it will say in the URL bar: www.com/profile.php?id=
I also know that this is what Facebook do for their profile system.
However they also have a feature called ‘usernames’ which allows you to get facebook.com/
which replaces facebook.com/profile.php?id=

I was wondering how I would be able to implement this.

Many thanks,
Aidan

You would have to get the web server to redirect queries to your page.

If you are running Apache (or your website hosting is running apache), you need to use an .htaccess file with rules that determine how traffic is redirected. An example file that might help you get started:

RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L]

This would give you the $_GET[‘q’] variable.

This article also may be of use:

http://wettone.com/code/clean-urls

Sponsor our Newsletter | Privacy Policy | Terms of Service