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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:50:52+00:00 2026-05-26T06:50:52+00:00

I saw several htaccess example disabling some files to access: <Files ~ \.(js|sql)$> order

  • 0

I saw several htaccess example disabling some files to access:

<Files ~ "\.(js|sql)$">
   order deny,allow
   deny from all
</Files>

for example, this prevents to access all .JS and .SQL files, the others are enabled. I want the contrary! I want those files to be ENABLED, all others to be prevented. How to achieve this?

  • 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-26T06:50:53+00:00Added an answer on May 26, 2026 at 6:50 am

    Vorapsak’s answer is almost correct. It’s actually

    order allow,deny
    <Files ~ "\.(js|sql)$">
       allow from all
    </Files>
    

    You need the order directive at the top (and you don’t need anything else).

    The interesting thing is, it seems we can’t just negate the regex in FilesMatch, which is… weird, especially since the “!” causes no server errors or anything. Well, duh.


    and a bit of explanation:

    The order cause tells the server about its expected default behaviour. The

     order allow,deny
    

    tells the server to process the “allow” directives first: if a request matches any allow directive, it’s marked as okay. Then the “deny” directives are evaulated: if a request matches any deny directives, it’s denied (it doesn’t matter if it was allowed in the first pass). If no matches were found, the file is denied.

    The directive

     order deny,allow
    

    works the opposite way: first the server processes the “deny” directives: if a request matches, it’s marked to be denied. Then the “allow” directives are evaulated: if a request matches an allow directive, it’s allowed in, even if it matches a deny directive earlier. If a request matches nothing, the file is allowed.

    In this specific case, the server first tries to match the allow directives: it sees that js and sql files are allowed, so a request to foo.js goes through; a request to bar.php matches no directives, so it’s denied.

    If we swap the directive to “order deny,allow”, then foo.js will go through (for being a js), and bar.php will also go through, as it matches no patterns.


    oh and, one more thing: directives in a section (i.e. < Files> and < Directory>) are always evaulated after the main body of the .htaccess file, overwriting it. That’s why Vorapsak’s solution did not work as inteded: the main .htaccess denied the request, then the < Files> order was processed, and it allowed the request.

    Htaccess is magic of the worst kind, but there’s logic to it.

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

Sidebar

Related Questions

Some time ago I saw a javascript library/development tool that takes several .js files
In several JavaScript libraries I saw this notation at the very beginning: /** *
I saw there are several apps on App Store that allow other computers to
I read spring docs on this subject several times, but some things are still
I saw several examples where the list of the source names were took from
I was looking through some of the .net source yesterday and saw several implementations
I saw this several times when browsing.. people are using @Inject annotation with their
Once I've, while working with VS, I saw several screens popping up in a
Several months (maybe even a year or two) ago, I saw an asp .net
Saw this piece of code in a Ruby on Rails book. This first one

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.