hi to all I want to create a personal url for every user registered. Once the user registered then I will dynamically create a folder respectively. My goal of this is, if every user I will create their own folder so they could upload and download their files. example user register : john_cruz his personal url is www.example.com/john_cruz any suggestions would greatly appreciated. thanks in advance Tirso
1. Create new directory upon registration 2. Make index.php file to fill the directory 2. Use .htaccess to rewrite the URL Done
use mod rewrite so that www.example.com/john_cruz maps to: www.example.com/index.php?name=john_cruz then index.php would use $_get['name'] to serve the right page.
And what, pray tell, is the benefit of that? He wants the shorter URL for a reason. In addition, using GET is a security risk in some cases. If he needs to worry about getting a variable from a URL, he can simply use the current URL to single out the directory that is already there. But in all honesty, it would be easier to use cookies with encryption applied.
Zac439, JDevereux was talking about mapping one URL to the other with the help of ModRewrite. User visits the short URL, but the code at the more convenient URL is executed. This is generally how it's done. However, if Tirso wants to actually create those directories for users to store their files in, it will take a little bit more .htaccess magic. First he needs to map the directory name to the index.php script the way JDevereux suggested, but he needs to make sure that the *contents* of that directory do not get rewritten to some useless URL and that they actually show up when users want to fetch them. However, I must confess that the specification of this problem wasn't clear enough for me to actually provide a 100% solution. And yes, I am just being nice, the specification really isn't clear enough, haha.
You could even use mod_rewrite to write every request to index.php and set it up as virtual subdomains, handled completely outside apache. For example, if your user was john it could be john.example.com and you parse out the name with PHP. Deviantart employs a similar method. Just a thought. I've used it and it's very effective