/    Sign up×
Community /Pin to ProfileBookmark

How point .png to .php at server level using php?

Hi all. could any one show me how i can point .png to .php instead at server level. The server that hosts the script has the fllowing info so i am not sure if it is the same as apache. Looking forward for reply.Thanks

System Linux ws6 2.6.17.8-SE #5 SMP Thu Sep 21 22:21:16 GMT 2006 i686
Server API CGI

to post a comment
PHP

13 Comments(s)

Copy linkTweet thisAlerts:
@sitehatcheryFeb 24.2007 — Not sure what you are asking here. Can you clarify?
Copy linkTweet thisAlerts:
@methodauthorFeb 24.2007 — Not sure what you are asking here. Can you clarify?[/QUOTE]

I mean when user browser calles :


<img src="http://www.somesite.com/[B]backround_image.png[/B]" border="0" width="175" height="221">


the server gives him instead


<img src="http://www.somesite.com/[B]backround_image.php[/B]" border="0" width="175" height="221">

The reason that i am looking for such solution because some sites that i work on does not allow dynamic extention for image. Hope some one help me here.
Copy linkTweet thisAlerts:
@aerodudeFeb 24.2007 — You can't do that with PHP. If you're using apache then look up mod_rewrite, that'll work.
Copy linkTweet thisAlerts:
@SheldonFeb 25.2007 — you can force the output with PHP to what ever you want.

look at http://php.net/gd for more
Copy linkTweet thisAlerts:
@NightShift58Feb 25.2007 — You can't do that with PHP. If you're using apache then look up mod_rewrite, that'll work.[/QUOTE]Wrong.

You can do that starting with plain HTML, which is what this is.

The only thing you must do is ensure that the PHP script used in <img src> actually returns a valid image - which could be accomplished using of the many techniques available in PHP.

And stay away from mod_rewrite for that...
Copy linkTweet thisAlerts:
@NogDogFeb 25.2007 — Among the several possibilities are the following:
[list=1]
  • [*]Just have the link point to a .php file in the first place.

  • [*]Use a "Redirect" statement in a .htaccess file on a case-by-case basis, e.g.: Redirect image.png http://www.yoursite.com/images/image.php

  • [*]Name your image-generating script with a .png suffix and use .htaccess to tell Apache to process it as a PHP application, something like:AddType application/x-httpd-php .png

  • [*]Use a .htaccess [url=http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html]mod_rewrite[/url] command to rename requests for .png files to be rewritten as requests for .php files

  • [*]Anything else we haven't though of yet
  • [/list]
    Copy linkTweet thisAlerts:
    @bokehFeb 26.2007 — Aerodude is right! It can't be done with PHP (without some reconfiguration outside PHP).
    Copy linkTweet thisAlerts:
    @NightShift58Feb 26.2007 — Aerodude is right! It can't be done with PHP (without some reconfiguration outside PHP).[/quote]
    <img src="http://www.somesite.com/[B]backround_image.php[/B]" border="0" width="175" height="221">[/QUOTE]I was referring to this - but on re-read, I just now realize that that was neither the point nor the question.

    Sorry. I promise not to do that again ... too often...
    Copy linkTweet thisAlerts:
    @sitehatcheryFeb 26.2007 — [code=php]
    <?php
    function replaceFile($content)
    {
    return (str_replace(".jpg", ".php", $content));
    }
    ?>

    <html>
    <body>
    <?php ob_start("replaceFile"); ?>

    <img src="http://www.somesite.com/backround_image.jpg" border="0" width="175" height="221">
    <?php ob_end_flush(); ?>
    </body>
    </html>
    [/code]
    Copy linkTweet thisAlerts:
    @aerodudeFeb 26.2007 — Aerodude is right! It can't be done with PHP (without some reconfiguration outside PHP).[/QUOTE]
    Thank you ? at least someone has the sense to read the question first and not slander others for trying to help :p
    Copy linkTweet thisAlerts:
    @bokehFeb 26.2007 — slander[/QUOTE]Don't you mean libel?
    Copy linkTweet thisAlerts:
    @aerodudeFeb 26.2007 — Don't you mean libel?[/QUOTE]

    Possibly, or maybe [I]castigation [/I]or [I]vituperation[/I].

    Although I haven't really thought about it that much.
    Copy linkTweet thisAlerts:
    @NightShift58Feb 26.2007 — The common law origins of defamation lie in the torts of slander (harmful statement in a transitory form, especially speech) and libel (harmful statement in a fixed medium, especially writing but also a picture, sign, or electronic broadcast), each of which gives a common law right of action.[/quote]Libel, if this forum will be kept as a legacy for generations to come. Is it more "volatile"? Then slander.

    They suggest "defamation", where the difference is not relevant.
    ×

    Success!

    Help @method spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.5,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...