nginx+thinkPhp配置虚拟主机和伪静态规则重写

Posted matengfei

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx+thinkPhp配置虚拟主机和伪静态规则重写相关的知识,希望对你有一定的参考价值。

/usr/local/nginx/conf/nginx.conf

进行配置

server
    {
        listen 80 default_server;
        #listen [::]:80 default_server ipv6only=on;
        server_name _;
        index index.html index.htm index.php;
        root  /home/wwwroot/default/duozhuan_cal_new;
        include  thinkphp.conf;
        #error_page   404   /404.html;

        # Deny access to php files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php.conf;

        location /nginx_status
        {
            stub_status on;
            access_log   off;
        }

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

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

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/access.log;
    }
include vhost/*.conf;

 

vhost下面的

server
    {
        listen 80;
        #listen [::]:80;
        server_name www.ma1.com ;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/www;

   include  thinkphp.conf;

        include other.conf;
        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php.conf;

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

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

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/y.log;
    }

 

这是thinkphp.conf,这是nginx的路由重写规则

location / {
    if (!-e $request_filename) {
        rewrite ^(.*)$ /index.php?s=/$1 last;
        break;
    }
}

 




















































































以上是关于nginx+thinkPhp配置虚拟主机和伪静态规则重写的主要内容,如果未能解决你的问题,请参考以下文章

静态nginx资源文件解析成路由怎么办thinkphp

thinkphp nginx 配置

nginx 配置web 虚拟文件夹 而且codeIgniter,thinkphp 重定向url 地址

thinkphp 3.2 nginx配置伪静态PUBLIC目录变成控制器如图,求高手指点

php伪静态配置

ThinkPHP怎么实现伪静态