开发者社区> 问答> 正文

nginx配置了伪静态 无效

下面是我的nginx配置文件,把伪静态代码放进去后,重新加载和重启nginx,网站的伪静态还是未生效,不知道哪里出问题了!麻烦网友帮我看看,谢谢!

user www www;
worker_processes auto;
error_log /www/wwwlogs/nginx_error.log crit;
pid /www/server/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;

events

{
    use epoll;
    worker_connections 51200;
    multi_accept on;
}

http

{
    include       mime.types;
    #include luawaf.conf;

    include proxy.conf;

    default_type  application/octet-stream;

    server_names_hash_bucket_size 512;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    client_max_body_size 50m;

    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 256k;
    fastcgi_intercept_errors on;

    gzip on;
    gzip_min_length  1k;
    gzip_buffers     4 16k;
    gzip_http_version 1.1;
    gzip_comp_level 2;
    gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
    gzip_vary on;
    gzip_proxied   expired no-cache no-store private auth;
    gzip_disable   "MSIE [1-6]\.";

    limit_conn_zone $binary_remote_addr zone=perip:10m;
    limit_conn_zone $server_name zone=perserver:10m;

    server_tokens off;
    access_log off;

server

{
    listen 888;
    server_name www.bt.cn;
    index index.html index.htm index.php;
    root  /www/server/phpmyadmin;

    #error_page   404   /404.html;
    include enable-php.conf;

location /{
rewrite ^app/list_(d+)_(d+).html$ /index.php?tpl=list_app&cid=$1&p=$2 break;
rewrite ^app/list_(d+).html$ /index.php?tpl=list_app&cid=$1&p=1 break;
rewrite ^app/(w+?)/(d+).html$ /index.php?tpl=list_app&cpy=$1&p=$2 break;
rewrite ^app/(w+?)/$ /index.php?tpl=list_app&cpy=$1&p=1 break;
rewrite ^sepcial/list_(d+).html$ /index.php?tpl=special_list&p=$1 break;
rewrite ^sepcial/$ /index.php?tpl=special_list&p=1 break;
rewrite ^special/(d+).html$ /index.php?tpl=special_content&id=$1 break;
rewrite ^info/list_(d+)_(d+).html$ /index.php?tpl=list_info&cid=$1&p=$2 break;
rewrite ^info/list_(d+).html$ /index.php?tpl=list_info&cid=$1&p=1 break;
rewrite ^info/(w+?)/(d+).html$ /index.php?tpl=list_info&cpy=$1&p=$2 break;
rewrite ^info/(w+?)/$ /index.php?tpl=list_info&cpy=$1&p=1 break;
rewrite ^info/(d+).html$ /index.php?tpl=content_info&id=$1 break;
rewrite ^app/(d+).html$ /index.php?tpl=content_app&id=$1 break;
rewrite ^app/(d+)_(d+).html$ /index.php?tpl=content_app_history&id=$1&hid=$2 break;
rewrite ^lastupdate/(d+).html$ /index.php?tpl=lastupdate&p=$1 break;
rewrite ^lastupdate/$ /index.php?tpl=lastupdate&p=1 break;
rewrite ^image/(.*).(w+)$ /pic.php?url=$1&type=$2 break;
}

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
        expires      30d;
    }

    location ~ .*\.(js|css)?$
    {
        expires      12h;
    }

    location ~ /\.
    {
        deny all;
    }

    access_log  /www/wwwlogs/access.log;
}

include /www/server/panel/vhost/nginx/*.conf;
}

展开
收起
手赚汇 2018-04-16 20:31:13 6217 0
3 条回答
写回答
取消 提交回答
  • 试试这个

    location / {
    	    if (-f $request_filename/index.html){
           	rewrite (.*) $1/index.html break;
       		}
       	    if (-f $request_filename/index.php){
           	rewrite (.*) $1/index.php;
       		}
       	    if (!-f $request_filename){
           	rewrite (.*) /index.php;
      	 	}
    	}
    
    2020-02-26 10:45:24
    赞同 展开评论 打赏
  • 例如 wordpress 博客系统,nginx 只要设置
    location / {

        if (!-e $request_filename) {
            rewrite (.*) /index.php;
        }
    }

    即可实现伪静态

    2019-07-17 22:05:52
    赞同 展开评论 打赏
  • 人要逍遥,心要自在,书剑不相及,飘零各一

    多点资料

    2019-07-17 22:05:52
    赞同 1 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
《Nginx 代理系统常用手册》 立即下载
CentOS Nginx PHP JAVA 多语言镜像使用手 立即下载
CentOS Nginx PHP JAVA多语言镜像使用手册 立即下载