Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3303574
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:58:16+00:00 2026-05-17T20:58:16+00:00

as most of you probably know, we can serve images from PHP using constructs

  • 0

as most of you probably know, we can serve images from PHP using constructs like this:

RewriteRule ^images/([a-zA-Z0-9]+)\.jpg script.php?image=$1

And then in PHP:

header('Content-Type: image/png');
$image=imagecreatefromjpeg($pathComputedSomewhereElse);
imagejpeg($image);

That’s dead simple, but that’s not my problem – i simply don’t want to confuse you.

My question is:

How can I, if it is possible, serve such image directly, using PHP only to fetch image path? I want Apache to do the work, not PHP reading file and outputting data as binary stream. Prototype markup would be as follows [same .htaccess]:

header('Content-Type: image/png');
header('Location: '.$pathComputedSomewhereElse);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:58:17+00:00Added an answer on May 17, 2026 at 8:58 pm

    If you have mod_xsendfile installed in your Apache, you can do exactly what you need without the client seeing the path they are redirected to.

    header("X-Sendfile: /path/to/your/filename");
    header("Content-type: image/jpeg");
    

    See a background article here

    Alternatively, if the client is allowed to see the new URL, I don’t see why using a 302 header wouldn’t work:

    header("Location: http://example.com/path/to/your/imagefile.jpg");
    die();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably a trivial question for most but here goes... I am using
Most of you probably know the following problem: You edit an HTML, view the
I think I probably know that the most common suggestion will be change the
We're using Infragistics grid (most probably, we'll have 8.2 version at the end) and
I'm about to write server side aplication(most probably it would be PHP but JAVA
This is probably seriously easy to solve for most of you but I cannot
I have a script that checks responses from HTTP servers using the PEAR HTTP
This is probably really obvious to most of you but i am new to
well i have most probably an extremly stupid problem but could not figure it
I'm looking for a non-linear curve fitting routine (probably most likely to be found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.