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

  • SEARCH
  • Home
  • 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 6152151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:52:20+00:00 2026-05-23T19:52:20+00:00

So I am building an application that necessitates redirecting (or is it rewriting? I

  • 0

So I am building an application that necessitates redirecting (or is it rewriting? I need to do the one where the URL remains the same on the client side) to a .php file for all requests that occur for .pdf files in a given directory on my web server (Apache). However, I only want this request to be rewritten if the user is trying to display the PDF in a browser (not download it). I have a feeling this second part is not possible.

Does anyone have some good resources to look into that not only depict the syntax that I will need to use but also what is going on behind the scenes with the Apache server?

Also, does anyone have an idea as to how I can determine if the file is being directly downloaded or requested via web-browser? I have a feeling that, since when you access a PDF file via a browser, it seems to download it and display it using the Adobe Reader plugin, that there is no distinction that can be made between the two.

Best regards,

  • 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-23T19:52:20+00:00Added an answer on May 23, 2026 at 7:52 pm
    <IfModule mod_rewrite.c>
       Options +FollowSymLinks
       Options +Indexes
       RewriteEngine On
    
       # only if not an actual file exist
       RewriteCond %{REQUEST_FILENAME} !-f
    
       # only if not an actual directory exist
       RewriteCond %{REQUEST_FILENAME} !-d
    
       RewriteRule /your-directory/path/(.+)\.pdf $1.php [NC,L]
    </IfModule>
    

    1. It is rewriting.

    2. There is no distinction between viewing and downloading. If a request is received by your Apache server, it will give a response. The response will be whatever your PHP script will output. Update: @corretge has given you an answer related to this. I think it’s not entirely reliable to rely on headers sent by the client, but you can try that solution.

    3. Here you can learn about Apache’s mode_rewrite

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building an application that's a host of various other applications (of sorts). One
I am building an application that will need to know these answers: Does the
I am building an application that will function as a client-server application, and also
I'm building a application that uses a file to configure some fonts. It's like
I'm building an application that uses a WCF client to retrieve data from my
I'm building an application that uses an UIScrollView. I need to detect when the
We are building an application that may need to be replicated to many servers
I'm building an application that needs to use a web server like a file
I'm building an application that serves up data to a standalone Google Earth client.
I am building an application that I will need to distinguish the Google Contacts

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.