[Apache] CPanel & .htaccess & php.ini 應用指南

Intro

CPanel的網頁伺服器是使用Apache搭建,可以支援.htaccess & php.ini的應用。


.htaccess

為Apache開啟AllowOverride後支援的檔案目錄設定檔功能,每個目錄皆能Override

以常見的轉導應用為例,.htaccess可參考以下:

RewriteEngine On

# 301 Redirect (Comment out)
# redirect 301 / https://www.google.com

# non-www redirect to www
RewriteCond %{HTTP_HOST} ^yourname.com [NC]
RewriteRule ^(.*)$ https://www.yourname.com/$1 [L,R=301]

[Apache][.htaccess] 停用PHP – Disable PHP

.htaccess file gives 500 internal server error


php.ini

預設建立在當前目錄下即會對當前目錄生效。

套用至所有子目錄 php.ini file recursive

隨一建置的.htaccess(一般文獻會建議建在/public_html),指定suPHP設定路徑:

suPHP_ConfigPath /home/username/public_html

旗下子目錄就會以這個指定目錄下的php.ini為主,當然還是能再被Override...

open_basedir


CPanel

  1. Web執行者為個別用戶

  2. 檔案管理員背景可sudo使MOD可改為000

Leave a Reply

Your email address will not be published. Required fields are marked *