请教一下这个nginx伪静态规则怎么放入宝塔面板不出错

查看 30|回复 5
作者:你踩踩踩踩   
请教一下这个nginx伪静态规则怎么放入宝塔面板不出错   或者说 这个要在哪里修改?能否指点一下
[color=#000]
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;    }}

宝塔, 静态

DRS   
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;  
    }  
    # Remove trailing slashes  
    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;  
    }  
    # Rewrite to index.php if the file does not exist  
    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; # 这里可能需要根据你的PHP-FPM配置调整  
        fastcgi_index index.php;  
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;  
        include fastcgi_params;  
    }  
    location ~ /\.ht {  
        deny all;  
    }  
}
DRS   
AI一下,你就知道

爬格子PA   
楼上的AI很厉害呀
abcdef   
宝塔里面选wordpress就可以了
情随   
DRS 发表于 2025-1-10 17:02
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;  
    }  
    # Remove trailing slashes  
    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;  
    }  
    # Rewrite to index.php if the file does not exist  
    if (!-e $request_filename) {  
        rewrite ^/(.*)$ /index.php?/$1 last;  
        break;  
    }  
    location / {  
        try_files $uri $uri/ /index.php?$qu ...

我直接放入宝塔的伪静态会跳错误,这个是不是要在文件里改
您需要登录后才可以回帖 登录 | 立即注册

返回顶部