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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:11:41+00:00 2026-06-07T01:11:41+00:00

I have my .htaccess file, and I have a folder with config files in

  • 0

I have my .htaccess file, and I have a folder with config files in there, and they contain sensitive content, e.g. database details etc. What I would like to know is, how can I block access from a browser, but allow them to be accessed via my scripts?

I know that this can be achieved inside the PHP files themselves, but I’d rather use the .htaccess approach where possible.

Is this actually able to be done? I’ve attempted it before, but in the process of denying access to the file from the browser, it also denied access from the coding.

I have looked into this before, and some of the answers I came across suggested changing the extension to something like .inc, and then denying access to that. However, a couple of issues I have with that is that a) It instantly alerts anyone that can see that filename, for whatever reason, that it is a config file. Also, b) If my denial code breaks, browsers will not parse it as a PHP file, but rather an inc file, meaning it will print the code in the browser.

Basically, can this be done within a .htaccess file, or do I need to put something in the header of every config file?

  • 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-06-07T01:11:45+00:00Added an answer on June 7, 2026 at 1:11 am

    Put these files outside of your web server’s document root.

    You can still access them via your server-side scripts, but this ensures no direct access to them from the outside world.

    • 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 is supposed to be redirecting any non-existing files/folders/etc
I have placed .htaccess file in my server's root folder with following content: Redirect
I have an .htaccess file with following content: AddHandler x-httpd-php5 .php For some reason,
My side resides in www.domain.com/Folder/Front.php So inside of Folder I have a .htaccess file
I have added a .htaccess file to my root folder, and i wanted everything
I have a .htaccess file in my htdocs/MVC/ folder which looks like this RewriteEngine
I have one .htaccess file in the public_html folder of my server that lets
I have a root folder htaccess containing my htaccess file and another folder,me containing
I have created a .htaccess and .htpasswd files, and stored them in the folder
So I have this .htaccess file in the /blog/ folder on my webserver and

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.