Jump to content

mysite.com/username -- How to redirect to profile using htaccess file ??


dilum

Recommended Posts

 

i have built a web site. that is a normal members register web site. so i want to give to member URL like this  www.mysite.com/username.

 

Example if some one type www.mysite.com/username so i want to display his profile with that same URL. like http://www.myspace.com/some_username

 

i think this one has to be solve in htaccess.  i tried lot of time but still i could not find a solution. so i want a help what i have to put to htaccess file and how i can read that from a PHP page (index.php)

:D

Thank you. 

Thanks for all the reply.

 

But still i have some problem.

 

I added these lines to htaccess file

 

RewriteEngine On

RewriteBase /

RewriteRule ^[a-zA-Z]*$ http://mydomain.com/index.php?username=$1

 

When I type "http://mydomain.com/smith"  Iit redirect to the index page.

This is the URL http://mydomain.com/index.php?username=

But I need that name also (smith) get details for that user. But in that URL passing only  username=

 

So can you help me how to get that name also to a variable?

 

Already i have declare a variable called $username = $_REQUEST['username'];

 

Thanks.

 

You all are missing a pair of round brackets here:

 

RewriteEngine On
RewriteBase /
RewriteRule ^([a-zA-Z]*)$ http://mydomain.com/index.php?username=$1

 

$1 refers to the first pair of round brackets, $2 to the second etc.

 

.. forget what was here, my mistake ..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.