.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:
errordocumentscreating 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.
errordocument 404 /error_pages/404.html
密码保护非常容易,我们可以对需要用户名和密码才能访问的应用程序目录进行密码保护。
authname "admin area"authuserfile /path/to/password/file/.htpasswdauthtype basicrequire valid-user
第一行告诉apache web服务器安全目录被称为'admin area',当弹出登录提示出现时,这将被显示出来。随后的一行指示密码文件的位置。第三行确定了认证类型,在这个例子中,我们使用'basic',因为我们使用基本的http认证,最后第四行表示我们需要有效的登录凭证
重定向重定向使我们能够将网站访问者从网站中的一个文档重定向到另一个文档。
redirect /old_dir/ http://www.test.com(your domain)/new_dir/index.html
拒绝访客根据ip地址order allow,denydeny from 155.0.2.0deny from 123.45.6.1allow from all
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 typesto set up a mime type, create a .htaccess file following the main instructions and guidance which includes the following text:
addtype text/html htm0
'addtype'确定您正在包含一个mime类型。后续部分是mime类型,在这种情况下是content或html,最后一部分是文件扩展名,在此示例中为'htm0'。
以上就是.htaccess是php中的什么?的详细内容。