目录
ErrorDocuments
密码保护
重定向
拒绝访客根据IP地址
Adding MIME types
首页 后端开发 php教程 .htaccess是PHP中的什么?

.htaccess是PHP中的什么?

Aug 27, 2023 pm 05:01 PM
php 功能 htaccess

.htaccess是PHP中的什么?

.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.

ErrorDocument 404 /error_pages/404.html
登录后复制

密码保护

非常容易,我们可以对需要用户名和密码才能访问的应用程序目录进行密码保护。

AuthName "Admin Area"
AuthUserFile /path/to/password/file/.htpasswd
AuthType Basic
require valid-user
登录后复制

第一行告诉Apache Web服务器安全目录被称为'Admin Area',当弹出登录提示出现时,这将被显示出来。随后的一行指示密码文件的位置。第三行确定了认证类型,在这个例子中,我们使用'Basic',因为我们使用基本的HTTP认证,最后第四行表示我们需要有效的登录凭证

重定向

重定向使我们能够将网站访问者从网站中的一个文档重定向到另一个文档。

Redirect /old_dir/ http://www.test.com(your domain)/new_dir/index.html
登录后复制

拒绝访客根据IP地址

order allow,deny
deny from 155.0.2.0
deny from 123.45.6.1
allow 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 types

To 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中的什么?的详细内容。更多信息请关注PHP中文网其他相关文章!

本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热门文章

仓库:如何复兴队友
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.能量晶体解释及其做什么(黄色晶体)
1 周前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒险:如何获得巨型种子
3 周前 By 尊渡假赌尊渡假赌尊渡假赌

热门文章

仓库:如何复兴队友
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.能量晶体解释及其做什么(黄色晶体)
1 周前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒险:如何获得巨型种子
3 周前 By 尊渡假赌尊渡假赌尊渡假赌

热门文章标签

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

适用于 Ubuntu 和 Debian 的 PHP 8.4 安装和升级指南 适用于 Ubuntu 和 Debian 的 PHP 8.4 安装和升级指南 Dec 24, 2024 pm 04:42 PM

适用于 Ubuntu 和 Debian 的 PHP 8.4 安装和升级指南

CakePHP 日期和时间 CakePHP 日期和时间 Sep 10, 2024 pm 05:27 PM

CakePHP 日期和时间

CakePHP 项目配置 CakePHP 项目配置 Sep 10, 2024 pm 05:25 PM

CakePHP 项目配置

CakePHP 文件上传 CakePHP 文件上传 Sep 10, 2024 pm 05:27 PM

CakePHP 文件上传

CakePHP 路由 CakePHP 路由 Sep 10, 2024 pm 05:25 PM

CakePHP 路由

讨论 CakePHP 讨论 CakePHP Sep 10, 2024 pm 05:28 PM

讨论 CakePHP

CakePHP 快速指南 CakePHP 快速指南 Sep 10, 2024 pm 05:27 PM

CakePHP 快速指南

如何设置 Visual Studio Code (VS Code) 进行 PHP 开发 如何设置 Visual Studio Code (VS Code) 进行 PHP 开发 Dec 20, 2024 am 11:31 AM

如何设置 Visual Studio Code (VS Code) 进行 PHP 开发

See all articles