
我想將 Ubuntu 上的 Apache Web 伺服器的 404 頁面自訂為常規頁面以外的頁面:
Not Found
The requested URL /***** was not found on this server.
______________________________________________________
Apache/*.*.** (Ubuntu) Server at **** Port 80
如何才能做到這一點?
答案1
我自己找到了答案。
您必須編輯檔案 /etc/apache2/conf.d/localized-error-pages
sudoedit /etc/apache2/conf.d/localized-error-pages
您可以輸入純文字或腳本或 html 的鏈接
答案2
<VirtualHost 192.168.0.1:80>
ServerAdmin [email protected]
ServerName host.ru
ServerAlias www.host.ru
DocumentRoot /home/WebServer/www/host.ru/public_html/
ErrorLog /home/WebServer/www/host.ru/logs/error.log
CustomLog /home/WebServer/www/hostu/logs/access.log combined
Alias /error_html/ "/home/WebServer/www/host/error_html/"
<Directory "/home/WebServer/www/host.ru/error_html">
AllowOverride None
Options IncludesNoExec
AddOutputFilter Includes html
AddHandler type-map var
Order allow,deny
Allow from all
LanguagePriority en cs de es fr it nl sv pt-br ro
ForceLanguagePriority Prefer Fallback
</Directory>
ErrorDocument 404 /error_html/HTTP_NOT_FOUND.html
</VirtualHost>
答案3
答案4
AFAIK 您無法以任何簡單的方式自訂 Apache 2.4 的預設錯誤訊息,因為這些訊息位於apache2
執行檔內。
但是,您可以使用“ErrorDocument”指令覆蓋它們,該指令也可以在apache2.conf
.
一種更好的方法是使用Include
inapache2.conf
並在一個單獨的檔案中收集覆蓋的訊息。
另請參閱Apache 2.4 文件。