77

I have copied one of my old applications and renamed it to New_application. I want to access .htaccess file that is inside the New_application folder. When I opened it with my text editor, it just showed Deny from all. I tried to open .htaccess in my old application, it showed Deny from all too. I remember I was able to edit it before but not sure what I can't now. Any thoughts? Thanks a lot.

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
FlyingCat
  • 14,036
  • 36
  • 119
  • 198

4 Answers4

190
Deny from all 

is an .htaccess command (the actual content of that file you are trying to view). Not a denial of being able to edit the file. Just reopen the .htaccess file in the text viewer of choice and make the alterations as you so desire, save it, then reupload it to your folder of choice.

Though I think inadvertently you are blocking even yourself from viewing said application once uploaded.

I would do something like:

order deny,allow
deny from all
allow from 127.0.0.1

which will deny everyone but the IP in the allow from line, which you would change the IP to match your IP which you can obtain from http://www.whatismyip.com/ or similar site.

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
chris
  • 36,115
  • 52
  • 143
  • 252
  • 3
    Goes without saying, but be wary of shared IP addresses! – John May 23 '13 at 19:44
  • 19
    `order deny, allow` should be `order deny,allow` (no space after `,`) otherwise some Apache versions will show Server Error because `order takes one argument, 'allow,deny', 'deny,allow'` (Says Apache Log) – adrianTNT Jul 03 '13 at 12:01
  • 1
    for windows users , make sure you make the file name exactly `.htaccess` by save-as the file from some text editor because windows explorer doesn't allow you to remove file names. it was a problem for me – Accountant م Aug 19 '16 at 20:02
  • 1
    Well, windows does allow you to, but you have to go about doing so in a roundabout way. Such as through the terminal (or CMD), you can also choose to show all files hidden and otherwise, as well as show file extensions from which you can make a .htaccess.txt that you can then remove the .txt from later since your showing the extensions. Also since your showing hidden files you can select and delete the file in explorer. Then as I said you can do it in the command line too. So its not impossible but windows does like to make it difficult sometimes. – chris Aug 21 '16 at 05:21
30

This syntax has changed with the newer Apache HTTPd server, please see upgrade to apache 2.4 doc for full details.

2.2 configuration syntax was

Order deny,allow
Deny from all

2.4 configuration now is

Require all denied

Thus, this 2.2 syntax

order deny,allow
deny from all
allow from 127.0.0.1

Would ne now written

Require local
gasp
  • 576
  • 4
  • 10
4

You can edit it. The content of the file is literally "Deny from all" which is an Apache directive: http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#deny

Sahand
  • 2,095
  • 1
  • 19
  • 24
0

A little alternative to @gasp´s answer is to simply put the actual domain name you are running it from. Docs: https://httpd.apache.org/docs/2.4/upgrading.html

In the following example, there is no authentication and all hosts in the example.org domain are allowed access; all other hosts are denied access.

Apache 2.2 configuration:

Order Deny,Allow
Deny from all
Allow from example.org

Apache 2.4 configuration:

Require host example.org
andiOak
  • 356
  • 3
  • 9