FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


dynamic file name?





mistuh griddlez
Wow...i've been highly inactive.....

Well anyways....how would i make a directory dynamic?

For example if i wanted to make one directory that will display any users profile (www.example.com/$user) how would i?

Thanks in advance! Very Happy

[the above part solved]

Ok ummm let's say i wanted a dynamic file name....how would i do that...?

basically www.example.com/$user.png
MrBlueSky
You can use mod_rewrite. Put the following in .htaccess in the directory:

Code:

RewriteEngine on
RewriteRule ^([^.]*)$ profile.php?user=$1 [L]


and write a script (profile.php) which takes a get parameter (user) and uses it to display the users profile.

For example:

when a user requests "www.example.com/john" this will be rewritten to "www.example/profile.php?user=john".
mistuh griddlez
OH MY GOD!!! YOU ARE AWESOME!!! YOU DON'T KNOW HOW LONG I'VE BEEN LOOKING FOR SOMETHING LIKE THIS!!!

Thank you so much...now I can actually make a good community website! Very Happy
mistuh griddlez
sorry about the double post but I have a new question (above)
MrBlueSky
mistuh griddlez wrote:


Ok ummm let's say i wanted a dynamic file name....how would i do that...?

basically www.example.com/$user.png


I'm not sure what you mean. Can you explain a little?
Fire Boar
RewriteRule is your friend. Smile Add this to the bottom of .htaccess (RewriteEngine should still be on).

Code:
RewriteRule ^([^.]*)\.png$ userimage.php?user=$1 [L]


And have userimage.php generate the image using the gd library.
mistuh griddlez
ok cool thanks! can I do that with any extension?

if so do i basically just change png to jpg or anything else?
Related topics
[Dreamweaver] Unwanted hyperlink file name case switching
553 Prohibited file name {SOLVED}
File upload with PHP, Build an upload database for your site
751 Useful Windows XP Files
Fortran Tutorials(77)
How to change text in file field?
Whats using [insert file name here]?
Upload file
core.18081 file
Can't Install Windows on New HD
HELP, reading text file from USB drive in visual basic
Can a php page generate a file?
file encryption problems...please help if you can
How to set up a home FTP server
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.