首頁  >  文章  >  後端開發  >  .htaccess是PHP中的什麼?

.htaccess是PHP中的什麼?

WBOY
WBOY轉載
2023-08-27 17:01:10845瀏覽

.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中文網其他相關文章!

陳述:
本文轉載於:tutorialspoint.com。如有侵權,請聯絡admin@php.cn刪除