Định nghĩa máy chủ của tôi có vấn đề gì? Nếu tôi cố gắng truy cập vào "www.testing.com", tôi nhận được một tệp nhị phân để tải xuống thay vì index.php, thay vào đó nếu tôi cố gắng truy cập vào "testing.com", tôi nhận được index.php.Không thể mở index.php theo mặc định bằng nginx
Tôi đã cố gắng để thiết lập servername để:
servername testing.com;
servername testing.com www.testing.com;
servername testing.com www.testing.com *.testing.com;
hành vi tương tự: Tôi không thể có được index.php với "www.testing.com", chỉ với "testing.com". (off course testing.com không phải của tôi chỉ là ví dụ).
user nginx;
worker_processes 4;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type text/plain;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
fastcgi_intercept_errors on;
sendfile on;
keepalive_timeout 65;
gzip on;
index index.php index.html index.htm;
server {
listen 80;
server_name www.testing.com;
root /home/vhosts/testing;
location/{
try_files $uri $uri/ /index.php index.php;
}
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
location ~* \.php$ {
try_files $uri =404;
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
}
}
}
Ý của bạn là anh không thể? – Purefan