TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 09-05-2010, 12:17 PM   #1 (permalink)
The Visitor
Newcomer 
 
Join Date: Aug 2010
Posts: 2
Thanks: 0
OpenBSD is on a distinguished road
Default Url Permalink

Hi,
How To change My Url to user friendly using php and mysql !
any Example :
i have this url for show user profile:
view source
print?
1 http://mydomain.com/showuser.php?id=30 //<- this link show user with id 30


change to friendly Url :
view source
print?
1 http://mydomain.com/user/john //<- this john is name of id 30


Thanks for any help.
OpenBSD is offline  
Reply With Quote
Old 09-05-2010, 03:41 PM   #2 (permalink)
The Addict
 
Enfernikus's Avatar
 
Join Date: Jun 2008
Posts: 335
Thanks: 2
Enfernikus is on a distinguished road
Default

This isn't just a PHP/MySQL functionality, read up on Apache's mod_rewrite (assuming you're running a LAMP stack)
__________________
My Blog
Enfernikus is offline  
Reply With Quote
Old 09-05-2010, 04:39 PM   #3 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

You can definitely make use of Apache's mod_rewrite or Nginx's HttpRewriteModule to aid in this endeavor. If you're using something other than Apache or Nginx, the first thing you should be doing is dumping it and installing one or the other of the aforementioned web servers. ;)

On to the point though, rewrite rules are an excellent way to perform simple tasks such as removing file extensions from the url, or redirecting all 404's to a single point of entry (amongst many other fancy tricks), but rewriting your entire site one section at a time is a little bit horrendous. Especially if you're attempting to create a distributable app.

While I think the author of this article is completely off base about the 'right' way to do things, and you have to take their opinion (as with mine) with a grain of salt, it is nevertheless a pretty good article on the basics of the subject. http://www.roscripts.com/Pretty_URLs...iting-168.html -- it will introduce you to the concepts of doing it either way so that you can make the final decision as to which is best for you; just remember that when you get to the part about doing it via PHP the first sentence makes it sound an awful lot like he is about to tell you the wrong way to do things and that if you can't grasp the earlier concept you must be learning disabled of some kind. What he doesn't mention is that nearly all major CMS software does it this way, as well as most of the major frameworks as well.
__________________
uʍop ǝpısdn sı ɹǝʇndɯoɔ ɹnoʎ sıɥʇ pɐǝɹ uɐɔ noʎ ɟı
delayedinsanity is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 08:52 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design