views:

46

answers:

1

I would like to display an image but have the file name different than the actual file name on the server.

ex) The user would see <img src="/img/photos/Awesome_Picture_By_John.jpg"> by looking at the source code

but the actual file name would be /img/photos/12b7dch2.jpg

any help is appreciated. Thx

+2  A: 

It can be done pretty easily. I think you could do something like this with mod_rewrite, turn the existing

/img/photos/Awesome_Picture_By_John.jpg

Into something like

/img.php?id=Awesome_Picture_By_John

and have img.php pull the real filename out of the database.

Here is a good mod_rewrite tutorial to get you started.

Jeremy Morgan
how long will this linkage have to remain in the rewrite rules? You might create a symbolic link to 12b7dch2.jpg by the name of Awesome_Picture_By_John.jpg. is there a possibility of wanting to call several things Awesome_Picture_By_John.jpg?
Don
The rewriting rule needs to be generalized, like: RewriteRule ^/img/photos/(.+)$ /serve_real_image_from_fancy_filename.php?fancy_filename=$1
Salman A