Re: [PHP] Best Practice to Create Dynamic URL's- With Username
- Original Message From: Gaurav Kumar kumargauravjuke...@gmail.com To: php-general@lists.php.net Sent: Monday, September 21, 2009 12:54:30 AM Subject: [PHP] Best Practice to Create Dynamic URL's- With Username Hi All, I am creating a social networking website. I want that every user should have there own profile page with a static URL like- http://www.abcnetwork/user/username Where username will be dynamic userid or something else. This is something very similar to www.youtube.com/user/kumargauravmail (this is my profile page). So what should be the best practice to create such DYNAMIC URL's OR what kind of methodology youtube is following? Thanks in Advance. Gaurav Kumar OSWebstudio.com Assuming the 'username' is from DB, look into URL rewrite. Thus, client see this http://www.abcnetwork/user/username which translates into this (or something similar) to PHP http://www.abcnetwork/userProfile.php?user=username Of course, you'll need to handle the 404 just in case ;) Regards, Tommy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best Practice to Create Dynamic URL's- With Username
On Mon, 2009-09-21 at 13:24 +0530, Gaurav Kumar wrote: Hi All, I am creating a social networking website. I want that every user should have there own profile page with a static URL like- http://www.abcnetwork/user/username Where username will be dynamic userid or something else. This is something very similar to www.youtube.com/user/kumargauravmail (this is my profile page). So what should be the best practice to create such DYNAMIC URL's OR what kind of methodology youtube is following? Thanks in Advance. Gaurav Kumar OSWebstudio.com If you're working on an Apache server, your best bet is to look at mod_rewrite. You can write a simple rule to match against these sorts of URL formats, so that to your visitors it appears as if the actual path exists, but internally it can get translated to something like http://www.abcnetwork.com/profile.php?id=username Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best Practice to Create Dynamic URL's- With Username
Hi, ... As has been suggested you could use mod_rewrite, but you don't have to if your needs are simple (or maybe you don't have it). You could also use the ForceType directive. Eg on my website the URLs are like this: http://www.phpguru.org/article/20-years-of-php Where article is actually a PHP file without the .php extension. It's forced to run as a PHP file using this: Files article ForceType application/x-httpd-php /Files And you will find the URL in $_SERVER somewhere. -- Richard Heyes HTML5 graphing: RGraph - www.rgraph.net (updated 5th September) Lots of PHP and Javascript code - http://www.phpguru.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best Practice to Create Dynamic URL's- With Username
A Big Thanks to all of you. Question I was Asked by Andrea- mod_reqrite or .htaccess is the answer, but I wonder why you choose /user/username rather than just /username a la twitter. I will be using many other aspects of my users something like /projects/username/; /gallery/username/. OK Ashley, Tommy and Ralph- 100% correct that mod_rewrite will be used. I am a bit sticky that my URL will be- http://www.abcnetwork/user/*Ashley*http://www.abcnetwork/user/username. So will I get $_GET[user] with value as *Ashley* or *Tommy* in my script? http://www.abcnetwork/userProfile.php?user=usernameSo what exactly will be the .htaccess rule for above? Thanks, Gaurav Kumar OSWebstudio.Com On Mon, Sep 21, 2009 at 1:26 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Mon, 2009-09-21 at 13:24 +0530, Gaurav Kumar wrote: Hi All, I am creating a social networking website. I want that every user should have there own profile page with a static URL like- http://www.abcnetwork/user/username Where username will be dynamic userid or something else. This is something very similar to www.youtube.com/user/kumargauravmail(this is my profile page). So what should be the best practice to create such DYNAMIC URL's OR what kind of methodology youtube is following? Thanks in Advance. Gaurav Kumar OSWebstudio.com If you're working on an Apache server, your best bet is to look at mod_rewrite. You can write a simple rule to match against these sorts of URL formats, so that to your visitors it appears as if the actual path exists, but internally it can get translated to something like http://www.abcnetwork.com/profile.php?id=username Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] Best Practice to Create Dynamic URL's- With Username
Question I was Asked by Andrea- mod_reqrite or .htaccess is the answer, but I wonder why you choose /user/username rather than just /username a la twitter. I will be using many other aspects of my users something like /projects/username/; /gallery/username/. well, it does not matter if this service is user based. /username/ #as user home page /username/projects/ #as user projects /username/gallery/ #as user gallery /username/etc ... it's just a silly point but from user home page you isntantly know if user exists and you instantly know subsections In your way you assume that there is a gallery for that user while he could have created only projects, without galleries. So one search failed, while to go in the user page I need to digit /user/ before, not a big deal but we are in tinyurl and bit.ly era Google Code put simply a /p/ as prefix plus the project name plus subsection /p/myprojname/ /p/myprojname/wiki since you are starting now, maybe you could consider this semantic alternative, if it suits your requirements. Regards Thanks, Ash http://www.ashleysheridan.co.uk _ More than messages–check out the rest of the Windows Live™. http://www.microsoft.com/windows/windowslive/
Re: [PHP] Best Practice to Create Dynamic URL's- With Username
I totally agree with this architecture. You are correct, I am just in the starting phase of the project and in fact still need to define the architecture in detail. Now the question I asked in my last reply is still to be answered? Gaurav Kumar OSWebstudio.Com On Mon, Sep 21, 2009 at 3:06 PM, Andrea Giammarchi an_...@hotmail.comwrote: Question I was Asked by Andrea- mod_reqrite or .htaccess is the answer, but I wonder why you choose /user/username rather than just /username a la twitter. I will be using many other aspects of my users something like /projects/username/; /gallery/username/. well, it does not matter if this service is user based. /username/ #as user home page /username/projects/ #as user projects /username/gallery/ #as user gallery /username/etc ... it's just a silly point but from user home page you isntantly know if user exists and you instantly know subsections In your way you assume that there is a gallery for that user while he could have created only projects, without galleries. So one search failed, while to go in the user page I need to digit /user/ before, not a big deal but we are in tinyurl and bit.ly era Google Code put simply a /p/ as prefix plus the project name plus subsection /p/myprojname/ /p/myprojname/wiki since you are starting now, maybe you could consider this semantic alternative, if it suits your requirements. Regards Thanks, Ash http://www.ashleysheridan.co.uk -- check out the rest of the Windows Live™. More than mail–Windows Live™ goes way beyond your inbox. More than messageshttp://www.microsoft.com/windows/windowslive/
Re: [PHP] Best Practice to Create Dynamic URL's- With Username
On Mon, 2009-09-21 at 15:20 +0530, Gaurav Kumar wrote: I totally agree with this architecture. You are correct, I am just in the starting phase of the project and in fact still need to define the architecture in detail. Now the question I asked in my last reply is still to be answered? Gaurav Kumar OSWebstudio.Com On Mon, Sep 21, 2009 at 3:06 PM, Andrea Giammarchi an_...@hotmail.com wrote: Question I was Asked by Andrea- mod_reqrite or .htaccess is the answer, but I wonder why you choose /user/username rather than just /username a la twitter. I will be using many other aspects of my users something like /projects/username/; /gallery/username/. well, it does not matter if this service is user based. /username/ #as user home page /username/projects/ #as user projects /username/gallery/ #as user gallery /username/etc ... it's just a silly point but from user home page you isntantly know if user exists and you instantly know subsections In your way you assume that there is a gallery for that user while he could have created only projects, without galleries. So one search failed, while to go in the user page I need to digit /user/ before, not a big deal but we are in tinyurl and bit.ly era Google Code put simply a /p/ as prefix plus the project name plus subsection /p/myprojname/ /p/myprojname/wiki since you are starting now, maybe you could consider this semantic alternative, if it suits your requirements. Regards Thanks, Ash http://www.ashleysheridan.co.uk __ check out the rest of the Windows Live™. More than mail– Windows Live™ goes way beyond your inbox. More than messages For help with the mod_rewrite, a Google search never goes amiss, first result I found for 'mod_rewrite example' is http://www.workingwith.me.uk/articles/scripting/mod_rewrite . I looked at it quickly and it does cover what you need. As for what you get as $_GET parameters, that's entirely up to you, and as you will see from the above link, it's fairly simple to mess about with. Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best Practice to Create Dynamic URL's- With Username
Thanks Ashley and all the folks out there... On Mon, Sep 21, 2009 at 3:25 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Mon, 2009-09-21 at 15:20 +0530, Gaurav Kumar wrote: I totally agree with this architecture. You are correct, I am just in the starting phase of the project and in fact still need to define the architecture in detail. Now the question I asked in my last reply is still to be answered? Gaurav Kumar OSWebstudio.Com On Mon, Sep 21, 2009 at 3:06 PM, Andrea Giammarchi an_...@hotmail.com wrote: Question I was Asked by Andrea- mod_reqrite or .htaccess is the answer, but I wonder why you choose /user/username rather than just /username a la twitter. I will be using many other aspects of my users something like /projects/username/; /gallery/username/. well, it does not matter if this service is user based. /username/ #as user home page /username/projects/ #as user projects /username/gallery/ #as user gallery /username/etc ... it's just a silly point but from user home page you isntantly know if user exists and you instantly know subsections In your way you assume that there is a gallery for that user while he could have created only projects, without galleries. So one search failed, while to go in the user page I need to digit /user/ before, not a big deal but we are in tinyurl and bit.ly era Google Code put simply a /p/ as prefix plus the project name plus subsection /p/myprojname/ /p/myprojname/wiki since you are starting now, maybe you could consider this semantic alternative, if it suits your requirements. Regards Thanks, Ash http://www.ashleysheridan.co.uk __ check out the rest of the Windows Live™. More than mail– Windows Live™ goes way beyond your inbox. More than messages For help with the mod_rewrite, a Google search never goes amiss, first result I found for 'mod_rewrite example' is http://www.workingwith.me.uk/articles/scripting/mod_rewrite . I looked at it quickly and it does cover what you need. As for what you get as $_GET parameters, that's entirely up to you, and as you will see from the above link, it's fairly simple to mess about with. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Best Practice to Create Dynamic URL's- With Username
- Original Message From: Ashley Sheridan a...@ashleysheridan.co.uk To: Gaurav Kumar kumargauravjuke...@gmail.com Cc: Andrea Giammarchi an_...@hotmail.com; php-general@lists.php.net Sent: Monday, September 21, 2009 2:55:20 AM Subject: Re: [PHP] Best Practice to Create Dynamic URL's- With Username On Mon, 2009-09-21 at 15:20 +0530, Gaurav Kumar wrote: I totally agree with this architecture. You are correct, I am just in the starting phase of the project and in fact still need to define the architecture in detail. Now the question I asked in my last reply is still to be answered? Gaurav Kumar OSWebstudio.Com On Mon, Sep 21, 2009 at 3:06 PM, Andrea Giammarchi wrote: Question I was Asked by Andrea- mod_reqrite or .htaccess is the answer, but I wonder why you choose /user/username rather than just /username a la twitter. I will be using many other aspects of my users something like /projects/username/; /gallery/username/. well, it does not matter if this service is user based. /username/ #as user home page /username/projects/ #as user projects /username/gallery/ #as user gallery /username/etc ... it's just a silly point but from user home page you isntantly know if user exists and you instantly know subsections In your way you assume that there is a gallery for that user while he could have created only projects, without galleries. So one search failed, while to go in the user page I need to digit /user/ before, not a big deal but we are in tinyurl and bit.ly era Google Code put simply a /p/ as prefix plus the project name plus subsection /p/myprojname/ /p/myprojname/wiki since you are starting now, maybe you could consider this semantic alternative, if it suits your requirements. Regards Thanks, Ash http://www.ashleysheridan.co.uk __ check out the rest of the Windows Live™. More than mail– Windows Live™ goes way beyond your inbox. More than messages For help with the mod_rewrite, a Google search never goes amiss, first result I found for 'mod_rewrite example' is http://www.workingwith.me.uk/articles/scripting/mod_rewrite . I looked at it quickly and it does cover what you need. As for what you get as $_GET parameters, that's entirely up to you, and as you will see from the above link, it's fairly simple to mess about with. Thanks, Ash http://www.ashleysheridan.co.uk Ash, What's the IP that the link you gave resolve to? I'm getting timed out for the DNS lookup on my end ... Thanks, Tommy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best Practice to Create Dynamic URL's- With Username
On Mon, 2009-09-21 at 03:42 -0700, Tommy Pham wrote: - Original Message From: Ashley Sheridan a...@ashleysheridan.co.uk To: Gaurav Kumar kumargauravjuke...@gmail.com Cc: Andrea Giammarchi an_...@hotmail.com; php-general@lists.php.net Sent: Monday, September 21, 2009 2:55:20 AM Subject: Re: [PHP] Best Practice to Create Dynamic URL's- With Username On Mon, 2009-09-21 at 15:20 +0530, Gaurav Kumar wrote: I totally agree with this architecture. You are correct, I am just in the starting phase of the project and in fact still need to define the architecture in detail. Now the question I asked in my last reply is still to be answered? Gaurav Kumar OSWebstudio.Com On Mon, Sep 21, 2009 at 3:06 PM, Andrea Giammarchi wrote: Question I was Asked by Andrea- mod_reqrite or .htaccess is the answer, but I wonder why you choose /user/username rather than just /username a la twitter. I will be using many other aspects of my users something like /projects/username/; /gallery/username/. well, it does not matter if this service is user based. /username/ #as user home page /username/projects/ #as user projects /username/gallery/ #as user gallery /username/etc ... it's just a silly point but from user home page you isntantly know if user exists and you instantly know subsections In your way you assume that there is a gallery for that user while he could have created only projects, without galleries. So one search failed, while to go in the user page I need to digit /user/ before, not a big deal but we are in tinyurl and bit.ly era Google Code put simply a /p/ as prefix plus the project name plus subsection /p/myprojname/ /p/myprojname/wiki since you are starting now, maybe you could consider this semantic alternative, if it suits your requirements. Regards Thanks, Ash http://www.ashleysheridan.co.uk __ check out the rest of the Windows Live™. More than mail– Windows Live™ goes way beyond your inbox. More than messages For help with the mod_rewrite, a Google search never goes amiss, first result I found for 'mod_rewrite example' is http://www.workingwith.me.uk/articles/scripting/mod_rewrite . I looked at it quickly and it does cover what you need. As for what you get as $_GET parameters, that's entirely up to you, and as you will see from the above link, it's fairly simple to mess about with. Thanks, Ash http://www.ashleysheridan.co.uk Ash, What's the IP that the link you gave resolve to? I'm getting timed out for the DNS lookup on my end ... Thanks, Tommy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I get 80.82.121.153 for it. You might have an issue with your DNS server. There are a lot of freely available alternative DNS servers about the world that you can use instead. I had to do that myself one time, when the DNS server issued by my ISP was misbehaving and I was getting lots of timeouts just like you are getting. Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php