目錄
非常容易,我們可以對需要使用者名稱和密碼才能存取的應用程式目錄進行密碼保護。
首頁 後端開發 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 htaccess can be mod 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 softache web server stm. Somewious configuration in softache web serverc. Somewion them.

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

密碼保護

非常容易,我們可以對需要使用者名稱和密碼才能存取的應用程式目錄進行密碼保護。

ErrorDocument 404 /error_pages/404.html
登入後複製

第一行告訴Apache Web伺服器安全目錄被稱為'Admin Area',當彈出登入提示出現時,這將被顯示出來。隨後的一行指示密碼檔案的位置。第三行確定了認證類型,在這個例子中,我們使用'Basic',因為我們使用基本的HTTP認證,最後第四行表示我們需要有效的登入憑證

##重定向

重定向使我們能夠將網站訪客從網站中的一個文件重新導向到另一個文件。

AuthName "Admin Area"
AuthUserFile /path/to/password/file/.htpasswd
AuthType Basic
require valid-user
登入後複製

拒絕訪客根據IP位址

Redirect /old_dir/ http://www.test.com(your domain)/new_dir/index.html
登入後複製

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:

order allow,deny
deny from 155.0.2.0
deny from 123.45.6.1
allow from all
登入後複製
'AddType '確定您正在包含一個MIME類型。後續部分是MIME類型,在這種情況下是content或HTML,最後一部分是檔案副檔名,在此範例中為'htm0'。

以上是.htaccess是PHP中的什麼?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
2 週前 By 尊渡假赌尊渡假赌尊渡假赌
倉庫:如何復興隊友
4 週前 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:25 PM

CakePHP 專案配置

CakePHP 日期和時間 CakePHP 日期和時間 Sep 10, 2024 pm 05:27 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

如何設定 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 開發

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

CakePHP 快速指南

See all articles