bolshas
bolshas

Reputation: 101

PHP generate image from url address

Is the following situation possible and how:

A user goes to an internet address: www.example.com/image/123.png

File 123.png does not exist - it is created at the moment of entering the address and outputed to the user via imagepng.

Currently I am doing it like www.example.com/image/?link=123.png

I do not have shell access to the server.

Andrius

Upvotes: 0

Views: 560

Answers (2)

Dalibor Karlović
Dalibor Karlović

Reputation: 568

If your hosting is using Apache, you can create a file called ".htaccess" in your document root (most often your "public_html" or "www" directory) with something like this (untested):

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^image/(.*)$ image/?link=$1

This is Apache's mod_rewrite functionality.

Upvotes: 3

Headshota
Headshota

Reputation: 21449

you can use url rewriting of your server (I assume you're using apache) to map any URL to your PHP-script. Here's some links for you:

http://httpd.apache.org/docs/current/mod/mod_rewrite.html

http://www.sitepoint.com/guide-url-rewriting/

Upvotes: 1

Related Questions