Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess twitter or facebook URL naming convention

For my Social Networking Site, I would like to build a facebook, or twitter similar URL rewriting naming convention.

Using Twitter as an example, they have pages labeled twitter.com/about and another page labeled twitter.com/{$username}

However, how do you differentiate between say a user who has registers on to our site as "about" then. From this we are going to have a server conflict between the user "about" and the page about.

What is the best way to handle this?

like image 433
Mike Silvis Avatar asked Nov 23 '25 12:11

Mike Silvis


1 Answers

Usually, you'll see this implemented so that conflicts are not possible. For instance, you could camp all users inside a virtual /users directory, or a subdomain: mysite.com/users/msilvis, or users.mysite.com/msilvis.

I would not recommend that you make all users accessible via the root directory of your site, because this could potentially restrain you from adding pages. For instance, suppose you do not have yet an "about" page, but a user registers and calls itself "about"; you're screwed.

If you still choose to do so, before registration, try an HTTP request to your website to the page the user would have. If you don't get a 404, then something already has that name.

like image 101
zneak Avatar answered Nov 26 '25 02:11

zneak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!