PDA

View Full Version : Myspace user redirection


BarrMan
07-03-2009, 03:42 AM
Hey,
I want to do something similar to myspace user redirection, which means I want to have on the website the option that you could view each user's profile by going to the fake folder of the username.

I want to do something like this:
Redirection will be from this address:
www.mywebsite.com/myusername/
To this address:
www.mywebsite.com/?u=myusername

The folder 'myusername' doesn't exist but it looks like it does.

Is there a way to do this with .htaccess or anything else?

If so, I'd much appreciate any help on that.

Thanks.

phpVar
07-04-2009, 07:16 AM
this might work:

RewriteEngine on
RewriteRule ^([\w|\d]+)\/?$ ./?u=$1 [R]

hoping that the username is using letters and numbers and no symbols
try it on the .htaccess

BarrMan
07-05-2009, 04:36 AM
Thanks for your reply. I did some editing to what you wrote and it worked. The only thing that isn't what I really wanted is to write the whole address rather than just change the address to this: ../?u=$1.

This is my code now:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([\w|\d]+)\/$ http://localhost/htaccess/?u=$1

Is there a way that I won't have to write the whole address and just put something like this?: ../?u=$1

Thanks.

phpVar
07-06-2009, 03:59 AM
i forget you must add your directory name to rewrite base, like:
RewriteBase /htaccess/
or just / if you are in documents root, try this after rewrite engine line.

BarrMan
07-06-2009, 04:11 AM
Thank you very very much. That's all I needed.