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 02-14-2009, 10:07 AM   #1 (permalink)
The Contributor
 
hello-world's Avatar
 
Join Date: Feb 2009
Posts: 73
Thanks: 30
hello-world is on a distinguished road
Default domain/user/usename

some website like youtube and myspace they provide to every user a link like domain/username. Do they create for each users a directory ?
hello-world is offline  
Reply With Quote
Old 02-14-2009, 01:40 PM   #2 (permalink)
The Contributor
 
Join Date: Jan 2009
Posts: 40
Thanks: 10
Scottymeuk is on a distinguished road
Default

Its called mod_rewrite. You use a .htaccess file to rewrite the url. For example:

The raw php URL will look like:

Code:
http://example.com/?user=Scottymeuk
But with the following mod_rewrite code in a .htaccess file (In the root):

Code:
RewriteEngine on
RewriteRule user/(.*)/$ /?user=$2

It will turn out like:

Code:
http://example.com/user/Scottymeuk
So overall, they are not real directories, they are actually getting the information from the database using php but its being rewrote using a .htaccess file.

Please note: I have not tested this code.
Scottymeuk is offline  
Reply With Quote
The Following User Says Thank You to Scottymeuk For This Useful Post:
hello-world (02-14-2009)
Old 02-14-2009, 11:51 PM   #3 (permalink)
The Contributor
 
Join Date: Feb 2009
Posts: 65
Thanks: 0
Krik is on a distinguished road
Default

You should write a tutorial.

For all the mod rewrite tutorials I have read that is the first one that I could clearly follow. Going to have to go change my rewrite rules.
Krik is offline  
Reply With Quote
Old 02-14-2009, 11:56 PM   #4 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by Krik View Post
You should write a tutorial.

For all the mod rewrite tutorials I have read that is the first one that I could clearly follow. Going to have to go change my rewrite rules.
If you do not know regular expressions, thing will be hard.
__________________

Village Idiot is offline  
Reply With Quote
Old 02-15-2009, 01:51 AM   #5 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

What are your current rewrite rules, Krik, out of curiosity?
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 02-15-2009, 03:05 PM   #6 (permalink)
The Contributor
 
Join Date: Jan 2009
Posts: 40
Thanks: 10
Scottymeuk is on a distinguished road
Default

You may also want to change the mod_rewrite code I gave you a bit for validation as at the moment any characters can be used in the URL but you only want to allow alphanumeric chars.
Scottymeuk is offline  
Reply With Quote
The Following User Says Thank You to Scottymeuk For This Useful Post:
hello-world (02-15-2009)
Old 02-16-2009, 05:22 AM   #7 (permalink)
The Wanderer
 
kokjj87's Avatar
 
Join Date: Oct 2008
Posts: 18
Thanks: 0
kokjj87 is on a distinguished road
Default

Here is one good tutorial for you:
http://www.addedbytes.com/apache/url...for-beginners/
kokjj87 is offline  
Reply With Quote
The Following User Says Thank You to kokjj87 For This Useful Post:
hello-world (02-16-2009)
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 02:19 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