.htaccess file is used to control the directory access
in Apache web server. Comparing to httpd.conf,
httpd.conf is global settings for apache.
.htaccess can be applied per folder, overwrite http.conf
1) Example 1 of .htaccess, prevent directory list
Options -Indexes
You will get message:
"Forbidden
You don't have permission to access /htaccess_test/ on this server."
2) Example 2, will not display .txt file
Options +Indexes
IndexIgnore *.txt
You can not see txt in list, but you still can access, to disable access to txt
<Files "*.txt">
Order deny,allow
Deny from all
</Files>
3) Example 3, deny all access
<Files "*">
Order deny,allow
Deny from all
</Files>
You will get
"Forbidden
You don't have permission to access /htaccess_test/ on this server."
Remember, no space between deny and allow, or you will get
error message
"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log."
4)For password protection
Create encrypted password for user name jiansen for
htpasswd -c /var/www/html/htaccess_test/.htpasswd jiansen
File permission:
chmod 644 /var/www/html/htaccess_test/.htpasswd
Make sure it can be read by apache, but can not read by outside
.htaccess:AuthType Basic
AuthName "Restricted access"
AuthUserFile "/var/www/html/htaccess_test/.htpasswd"
Require valid-user
<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>
Video: Some examples of .htaccess
Hello
ReplyDeleteWe are professional traders, earning on forex and binary for investors weekly, will love to tell you all more about our investment platform where you can invest funds as little as $200 and start earning $2500 weekly, alot of people has benefited from this investment offer before and during this convid-19 virus, if you passing through financial difficulties due to this coronavirus and you need help paying bills simply choose a suitable investment plan for yourself and start making profit weekly
$500 to earn $5,000 in 7 days
$1000 to earn $10000 in 7 days
$5000 to earn $50000 in 7 days
To Start your investment now contact Via whatsapp: (+12166263236)
email: carlose78910@gmail.com