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 771855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:43:08+00:00 2026-05-14T18:43:08+00:00

I have a .htaccess file set up to define specific MIME types in directory

  • 0

I have a .htaccess file set up to define specific MIME types in directory root/a/b/, and all of the files are in the same directory.

I have a php file that wants to serve those files, in directory root/c/, and needs to determine the content-type as defined by the .htaccess file.

Is there any way to do this? PHP version is 5.1.6. mime_content_type returns text/plain, and I’d rather not try to parse the .htaccess file manually. I can move the file if necessary.

  • 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-14T18:43:09+00:00Added an answer on May 14, 2026 at 6:43 pm

    if you want to serve the files with php, why don’t you also define the mime types with php (eg. as an associative array with extension => mime type pairs)?

    that being said, a possible way to achieve this without parsing the .htaccess file would be to let the php script do a request for the file in root/a/b and check the mime type in the response headers. if you serve the files with the HTTP wrapper, eg. fopen('http://example.com/a/b/file'), you get this automatically: you can access the response headers via $http_response_header or stream_get_meta_data – the mime type is in the Content-Type: header. if you open the file another way, you can still do a HEAD request first and check the response Content-Type (even though doing 2 requests for every file served seems overkill).

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

Sidebar

Related Questions

I have an htaccess file that uses mod_rewrite to redirect /controller to /index.php?controller=%controller% Like
I have an .htaccess file set up like so: RewriteEngine on RewriteRule ^home/ /member.php
I have a very simple .htaccess file set up to redirect a 404 to
I have an .htaccess file that is not working properly. And it used to.
So I have this .htaccess file in the /blog/ folder on my webserver and
I have a relatively complex .htaccess file to control page requests, this currently redirects
I have DocumentRoot /var/www/test in my .htaccess file. This is causing the apache server
I have this htaccess code: RewriteEngine on RewriteBase /xm/ RewriteCond %{REQUEST_URI} !^/index.php$ RewriteRule ^([a-z0-9]*)\.php$
I have pushed my .htaccess files to the production severs, but they don't work.
I have quite a few RewriteRules in my .htaccess that looks like this RewriteRule

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.