【问题标题】:In PHP : What is the .htaccess file and what it will do?在 PHP 中:什么是 .htaccess 文件,它会做什么?
【发布时间】:2015-07-03 22:54:46
【问题描述】:

任何人都可以为 .htaccess 文件提供简单而简短的答案。在简单易懂的世界中描述这一点。

【问题讨论】:

  • .htaccess 是 Apache Web 服务器的功能,而不是 PHP,并且在 Apache 站点上有详细的文档。
  • 我投票决定将此问题作为题外话结束,因为复制/粘贴 Apache 的文档效率不高。请去阅读它们。如果您有关于该文件格式的具体问题,请在适当的网站上提问。

标签: php .htaccess


【解决方案1】:

.htaccess 是在运行 Apache Web 服务器软件的 Web 服务器上使用的配置文件。当 .htaccess 文件被放置在一个目录中时,该目录又“通过 Apache Web 服务器加载”,然后 .htaccess 文件被 Apache Web 服务器软件检测并执行。这些 .htaccess 文件可用于更改 Apache Web 服务器软件的配置,以启用/禁用 Apache Web 服务器软件必须提供的附加功能和特性。这些设施包括基本的重定向功能,例如,如果发生 404 文件未找到错误,或者更高级的功能,如内容密码保护或图像热链接预防。

以下是您可能包含在 .htaccess 文件中的示例。

AuthName "Member's Area Name"
AuthUserFile /path/to/password/file/.htpasswd
AuthType Basic
require valid-user
ErrorDocument 401 /error_pages/401.html
AddHandler server-parsed .html 

【讨论】:

    猜你喜欢
    • 2011-01-19
    • 1970-01-01
    • 2017-11-02
    • 2011-02-13
    • 1970-01-01
    • 2011-10-28
    • 2021-05-29
    • 2011-07-12
    • 2015-12-31
    相关资源
    最近更新 更多