.htaccess是PHP中的什麼?

WBOY
發布: 2023-08-27 17:02:02
轉載
873 人瀏覽過

.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
最新問題
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!