Forum Moderators: phranque

Message Too Old, No Replies

Create fake subfolder by .htaccess

         

smagdy

11:46 pm on Aug 2, 2009 (gmt 0)

10+ Year Member



Hi,

I want to create unique url for the registered users, just same way as the new usernames system in facebook.

So I don't know if they should be a real directories, or I can just trick it in the .htaccess?

I want users, to go to www.mysite.com/username and that will be a login page for each user!

if possible through .htaccess then please tell me its code.

Thanks in advance!

jdMorgan

12:24 am on Aug 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is a problem with this, and that can be illustrated by a question: What happens if I sign up for a user-account, and use the name "images"? How about "stats," "cgi-bin," "blog," or "forum"?

A better approach is to use example.com/users/<username> or users.example.com/<username>, or <username>.example.com/, as these methods prevent 'collisions' with real directories that you need to run your site.

Jim

smagdy

8:29 am on Aug 3, 2009 (gmt 0)

10+ Year Member



Thanks for the advice,

i would choose username.example.com

i have VPS so i can control everything as i know this requires some extra settings (i think)
so can you tell me the easiest way to dynamically create tese subdomains by PHP?

Thanks

g1smd

7:18 pm on Aug 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You'll need a rewrite. The rewrite will connect a URL request like
/username
to the internal file at /script.php?user=username.

smagdy

7:26 pm on Aug 3, 2009 (gmt 0)

10+ Year Member



Thanks, I just fixed it by using this easy tutorial!

[wiredstudios.com...]

g1smd

11:55 pm on Aug 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Let's see your code. There's likely some improvements that can be made.

smagdy

8:24 am on Aug 4, 2009 (gmt 0)

10+ Year Member



Hi,

All the code is in the link I gave you in previous message, thought its mostly settings and just code in PHP to catch the subdomain, nothing in .htaccess at all.