*
The moose likes PHP and the fly likes Trouble in restricting the directory which contains .htaccess file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Languages » PHP
Bookmark "Trouble in restricting the directory which contains .htaccess file" Watch "Trouble in restricting the directory which contains .htaccess file" New topic
Author

Trouble in restricting the directory which contains .htaccess file

sashwat kumar padhy
Greenhorn

Joined: Jun 12, 2013
Posts: 20

While i try to access the .htaccess file its saying access forbidden,which is obvious. But the listing of all other files also getting displayed,i.e no restrictions are imposed on those files which are under the same directory as the .htaccess. However i want to restrict everyone but myself from those files too. Here is my httpd.config

inside directory of httpd.config
Options Indexes FollowSymLinks Includes ExecCGI

AllowOverride ALL

Require all granted

<Files ".ht*">
Require all denied
</Files>

my .htaccess file
# deny everyone but myself
<Limit GET POST PUT>
Options -Indexes
Order allow,deny
Deny from all
</Limit>
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2231
    
    7

Just how are you planning to distinguish yourself from everyone else?


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
sashwat kumar padhy
Greenhorn

Joined: Jun 12, 2013
Posts: 20

K. Tsang wrote:Just how are you planning to distinguish yourself from everyone else?


Actually i could use ALLOW FROM xxx.xx.xx.x(my ip adress) but i don't have a static ip. So is there any way to use php,so that it can automatically get the current ip and set it in the .htaccess?
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2231
    
    7

sashwat kumar padhy wrote:
K. Tsang wrote:Just how are you planning to distinguish yourself from everyone else?


Actually i could use ALLOW FROM xxx.xx.xx.x(my ip adress) but i don't have a static ip. So is there any way to use php,so that it can automatically get the current ip and set it in the .htaccess?


If you could get the IP it's most likely the internal router IP (192.168.x.x) rather than the public router IP. Once you have your IP, I don't think you can "dynamically" change the .htaccess file.

Actually what do you want to do exactly? Reading the content of the .htaccess file? Browsing the files in directory?

If it is the latter, then you can simply write a PHP script and the .htaccess file is not needed at all.
sashwat kumar padhy
Greenhorn

Joined: Jun 12, 2013
Posts: 20

K. Tsang wrote:
sashwat kumar padhy wrote:
K. Tsang wrote:Just how are you planning to distinguish yourself from everyone else?


Actually i could use ALLOW FROM xxx.xx.xx.x(my ip adress) but i don't have a static ip. So is there any way to use php,so that it can automatically get the current ip and set it in the .htaccess?


If you could get the IP it's most likely the internal router IP (192.168.x.x) rather than the public router IP. Once you have your IP, I don't think you can "dynamically" change the .htaccess file.

Actually what do you want to do exactly? Reading the content of the .htaccess file? Browsing the files in directory?

If it is the latter, then you can simply write a PHP script and the .htaccess file is not needed at all.


The whole directory listing is restricted if .htaccess is present in that directory. This is exactly what i want for every user who tries to access the directory,however i want myself to have access to that directory listing for me only being the owner of those files. Without having a static ip,how to achieve it,that's my concern.
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2231
    
    7

Well I'm not security guy or Linux/Apache admin. But I can tell you this: from brief search, allowing IP to bypass .htaccess is unreliable. If the protected directory has an index.php page then you got a way in.

bypass .htaccess <- click
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Trouble in restricting the directory which contains .htaccess file
 
Similar Threads
Change html document path in Apache
apache (tomcat) not parsing XML file?
mail() is not working inn PHP script
First script for PHP is not working
Help