在 linux 中安裝 lnmp Nginx 的設定 問題
PHPz
PHPz 2017-05-16 17:23:16
0
1
752

Nginx 下有很多網域網站 當網域名稱解析到伺服器上的 時候 造訪時 報錯了 403 或404

因為伺服器還沒有配置 域名, 在直接存取伺服器的ip 時 也是報錯的

404 Not Found

nginx/1.4.4

403 Not Found

nginx/1.4.4
這樣的錯誤 我想修改一下 這樣報錯訊息!對 是 網域解析到伺服器了 而伺服器 沒有做該網域的設定; 報了403錯誤 或 存取伺服器 ip 位址

nginx.conf 如下 該怎麼配置自訂的 403 和 404 呢


user www www; worker_processes 1; error_log /alidata/log/nginx/error.log crit; pid /alidata/server/nginx/logs/nginx.pid; #Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 65535; events { use epoll; worker_connections 65535; } http { include mime.types; default_type application/octet-stream; #charset gb2312; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 8m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; fastcgi_intercept_errors on; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; #limit_zone crawler $binary_remote_addr 10m; log_format '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; include /alidata/server/nginx/conf/vhosts/*.conf; }
PHPz
PHPz

学习是最好的投资!

全部回覆(1)
PHPzhong

http://nginx.org/en/docs/http/ngx_http_core_module.html#error_page
自訂404頁,例如交給PHP處理:

error_page 404 = /404.php;

403類似.

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