gpt4 book ai didi

php - nginx 替代索引不起作用

转载 作者:搜寻专家 更新时间:2023-10-31 21:59:30 24 4
gpt4 key购买 nike

在转到子域时尝试让 login.php 或/login 成为索引页面,但我得到的只是一个空白页面。

配置如下:

server {
listen 80;
server_name *.domain.org;

root /var/www/html/domain.org/public;
index login login.php index.php index.html index.htm;

location ~* \.(css|js|png|woff2|woff|ttf|jpg|jpeg|gif|ico)$ {}

location = / {
index login.php;
}

location / {
try_files $uri $uri.php login;
rewrite ^(.*)$ $uri.php;
}

error_page 404 404;

location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

最佳答案

对我有用:

server {
listen 80;
server_name *.domain.org;

root /var/www/html/domain.org/public;
index index.php index.html index.htm;

location ~* \.(css|js|png|woff2|woff|ttf|jpg|jpeg|gif|ico)$ {}

location / {
index login.php;
}

error_page 404 404;

location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

如果仍然无法正常工作,请尝试将日志记录添加到服务器指令并查看出了什么问题:

error_log /var/www/html/domain.org/public/nginx-error.log;
access_log /var/www/html/domain.org/public/nginx-access.log;

关于php - nginx 替代索引不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30805334/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com