PHP string to image

Using mod_rewrite to handle various content issues

PHP string to image

Postby Fez » Thu Sep 18, 2008 12:01 pm

hey, i was wondering
if i had a file
http://www.example.com/script/image.php=username
and I wanted to turn it into
http://www.example.com/image/username.png
Where username is a variable and changes depending on what the user input so if someone requests http://www.example.com/image/fez.png its actually being taken from http://www.example.com/script/image.php=fez and being rewritten
how would I do that?

thanks in advance
Fez
 
Posts: 1
Joined: Thu Sep 18, 2008 11:50 am

Postby richardk » Fri Sep 19, 2008 6:51 am

Yes, try the following in a .htaccess file in your doucment root
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^image/([^/]+)\.png$ /script/image.php?username=$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Content

Who is online

Users browsing this forum: No registered users and 20 guests

cron