cccc 发表于 2025-1-10 16:50:21

宝塔面板怎么用server伪静态规则

我网上下载一个源码,但是只有给一个server的写法,请问这个要怎么转化?我直接在伪静态选项卡那边保存直接提示错误server {    listen 80 default_server;    server_name example.com www.example.com;    access_log /srv/www/example.com/logs/access.log;    error_log /srv/www/example.com/logs/error.log;    root /srv/www/example.com/public;    index index.php index.html;    # serve static files directly    location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {      access_log off;      expires max;      log_not_found off;    }    # removes trailing slashes (prevents SEO duplicate content issues)    if (!-d $request_filename)    {      rewrite ^/(.+)/$ /$1 permanent;    }    # enforce NO www    if ($host ~* ^www\.(.*))    {      set $host_without_www $1;      rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;    }    # unless the request is for a valid file (image, js, css, etc.), send to bootstrap    if (!-e $request_filename)    {      rewrite ^/(.*)$ /index.php?/$1 last;      break;    }    location / {      try_files $uri $uri/ /index.php?$query_string;    }    location ~* \.php$ {      try_files $uri = 404;      fastcgi_split_path_info ^(.+\.php)(/.+)$;      fastcgi_pass unix:/var/run/php8.0fpm.sock; # may also be: 127.0.0.1:9000;      fastcgi_index index.php;      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;      include fastcgi_params;    }    location ~ /\.ht {      deny all;    }}
页: [1]
查看完整版本: 宝塔面板怎么用server伪静态规则