.htaccess
is a configuration file for use on web servers running on the web apache server software. when a
.htaccess
file is placed in a directory which in turn loaded via the Apache web server, then the .htaccess file detected and executed by the Apache server software.
.htaccess
files can be utilized to modify the setup of the Apache server software to empower additional functionality and fetures that the apache web server softwatre brings to the table. We can use the .htaccess file for alteration various configuration in apache web server software. Some of them are listed below:
ErrorDocuments
Creating custom error pages is very useful, it allows us to show web site visitors a friendly error message, in case of if a URL on your web site does not work.
密码保护
非常容易,我们可以对需要用户名和密码才能访问的应用程序目录进行密码保护。
立即学习
“
PHP免费学习笔记(深入)
”;
第一行告诉Apache Web服务器安全目录被称为'Admin Area',当弹出登录提示出现时,这将被显示出来。随后的一行指示密码文件的位置。第三行确定了认证类型,在这个例子中,我们使用'Basic',因为我们使用基本的HTTP认证,最后第四行表示我们需要有效的登录凭证
PHP 8.5.5
PHP 8.5.5 是 PHP 8.5 分支的维护更新版本。该版本延续了“小步快跑”的迭代逻辑,通过深度错误修复、底层性能微调以及安全加固,旨在为开发者提供一个更健壮、更高效的运行环境。该版本严格遵守语义化版本规范,不包含破坏性变更。
下载
重定向
重定向使我们能够将网站访问者从网站中的一个文档重定向到另一个文档。
拒绝访客根据IP地址
The above lines tell the Apache Web Server to block visitors from the IP address '155.0.2.0' and '123.45.6.1' and allow all other IP addresses.
Adding MIME types
To set up a MIME type, create a .htaccess file following the main instructions and guidance which includes the following text:
'AddType'确定您正在包含一个MIME类型。后续部分是MIME类型,在这种情况下是content或HTML,最后一部分是文件扩展名,在此示例中为'htm0'。
ErrorDocument 404 /error_pages/404.htmlAuthName "Admin Area"
AuthUserFile /path/to/password/file/.htpasswd
AuthType Basic
require valid-userRedirect /old_dir/ http://www.test.com(your domain)/new_dir/index.htmlorder allow,deny
deny from 155.0.2.0
deny from 123.45.6.1
allow from allAddType text/html htm0