folders on server
/test
/test1
/test2
.htaccess
Order Deny,Allow
Deny from all
Allow from **.***.***.**
<Directory /test>
Options +Indexes
Allow from all
</Directory>
We are use .htaccess but adress http://test.com/test/ not work. Tell me please where errror ?
Related
I have .htaccess file:
Order deny,allow
Deny from all
# deny view files in directory
Options -Indexes
<FilesMatch "index\.php|profile\.php|newgame\.php|game\.php">
Allow from all
</FilesMatch>
It works well, I can open index.php or profile.php for url like site.com/index.php. But I can't open site for url site.com. Why? I give access to index.php. Isn't site.com the same of site.com/index.php. How to change .htaccess file to take into account this situation?
UPDATE
apache2.conf contains:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
You need to configure apache to recognize index.php as index file.
Add
DirectoryIndex index.php
i have a directory with .htaccess with deny
deny from all
and inside that directory there is another directory with .htaccess like this:
<Directory "/dir1/dir2">
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
How can i deny the access to second directory with htaccess on first directory?
Thanks for answers.
<Files *>
deny from all
</Files>
did the job :)
We have many, many sites, all of which contain a "customer/uploadsfolder". We have to allow uploading, but want to block any GIF files, as well as turn off PHP in the folder as shown below. The question is, do we need one entry for every folder, or can wildcards/regex be used?
<VirtualHost *:80>
<Directory /customer/uploadsfolder>
deny from all
<Files ~ "^\w+\.(gif)$">
order deny,allow
allow from all
</Files>
<IfModule mod_php5.c>
php_flag engine off
</IfModule>
</Directory>
</VirtualHost>
Yes, use LocationMatch (or "Location ~").
<LocationMatch "\/customer\/uploadsfolder\/.*\.(php|gif)">
order allow,deny
deny from all
</LocationMatch>
I'm trying to list files in one particular directory and with one particular ip. This htaccess file is located in that directory. So far, it seems that the hosting does not allow me to list directories. On localhost i can list everything in that directory, except the IndexIgnore ones, of course. The htaccess file content is:
Options +Indexes
<Limit GET POST>
order deny,allow
deny from all
allow from 1.1.1.1
</Limit>
IndexIgnore tabele_remote.php
IndexIgnore demo.txt
IndexIgnore functions.php
IndexIgnore config.php
It seems that AllowOverride directive is set somewhere previously
Also check there is no IndexIgnore * set on the parent directories or server entirely
change order deny,allow to order allow,deny and give it a try.
Also set AllowOverride all
I'm configuring an Apache2 server, but I'm having trouble figuring out how to deny access to all files/directories except the index file.
My website resides inside /var/www/
This is my current setup in the /etc/apache2/apache2.conf file:
<Directory />
Order Deny,Allow
Deny from all
Options None
AllowOverride None
</Directory>
<Directory /var/www/>
Order Allow,Deny
Allow from all
</Directory>
How do I solve my problem? Thanks!
Try adding a <FilesMatch> for index.php. If it doesn't work in this position, move it above the directory's Deny from all. Change index.html to whatever your index file is.
<Directory />
Order Deny,Allow
Deny from all
Options None
AllowOverride None
</Directory>
<Directory /var/www/>
# Deny first, then allow
Order deny,allow
# Deny everyone from everything
Deny from all
<FilesMatch index\.html>
# but allow index.html
Allow from all
</FilesMatch>
</Directory>
I think you're better off simply piping everything to the index file, not denying access to everything else.
This can be done through RewriteRule:
RewriteEngine On
# index goes to index (this is first to prevent infinite loop)
RewriteRule ^/index\.html$ - [L]
# everything else goes to index
RewriteRule .* /index.html [L]