Home > Backend Development > PHP Tutorial > laravel如何设置nginx伪静态?

laravel如何设置nginx伪静态?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:34:09
Original
1982 people have browsed it

按照官网设置的直接不解析网页变成下载了,试了网上的很多版本也没用。
用的是LNMP一键安装环境。

我的vhost配置信息:

<code>server
    {
        listen 80;
        #listen [::]:80;
        server_name domain.com;
        index index.html index.htm index.php default.html default.htm default.php server.php;
        root  /home/wwwroot/domain.com/public;

        #error_page   404   /404.html;
        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }
        location ~ [^/]\.php(/|$)
            {
                # comment try_files $uri =404; to enable pathinfo
                try_files $uri =404;
                fastcgi_pass  unix:/tmp/php-cgi.sock;
                fastcgi_index index.php;
                include fastcgi.conf;
                #include pathinfo.conf;
            }

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

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

        access_log  /home/wwwlogs/domain.log  access;
    }
</code>
Copy after login
Copy after login

回复内容:

按照官网设置的直接不解析网页变成下载了,试了网上的很多版本也没用。
用的是LNMP一键安装环境。

我的vhost配置信息:

<code>server
    {
        listen 80;
        #listen [::]:80;
        server_name domain.com;
        index index.html index.htm index.php default.html default.htm default.php server.php;
        root  /home/wwwroot/domain.com/public;

        #error_page   404   /404.html;
        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }
        location ~ [^/]\.php(/|$)
            {
                # comment try_files $uri =404; to enable pathinfo
                try_files $uri =404;
                fastcgi_pass  unix:/tmp/php-cgi.sock;
                fastcgi_index index.php;
                include fastcgi.conf;
                #include pathinfo.conf;
            }

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

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

        access_log  /home/wwwlogs/domain.log  access;
    }
</code>
Copy after login
Copy after login

我的配置是这样的:

<code>server
{
    listen       80;
    server_name b.phodal.com;
    index index.html index.htm index.php default.html default.htm default.php;
    root  /home/www/MK_iot/public;

    include other.conf;
    location ~ .*\.(php|php5)?$
        {
            try_files $uri =404;
            fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_index index.php;
            include fcgi.conf;
        }

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

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

     if (!-d $request_filename)
            {
                rewrite ^/(.+)/$ /$1 permanent;
            }

            # removes trailing "index" from all controllers
            if ($request_uri ~* index/?$)
            {
                rewrite ^/(.*)/index/?$ /$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;
            }

    access_log  /home/wwwlogs/b.phodal.com.log  b.phodal.com;
}
</code>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Composer cannot install laravel
From 1970-01-01 08:00:00
0
0
0
Laravel Space/laravel-backup cannot be installed
From 1970-01-01 08:00:00
0
0
0
Laravel 5.1 Login laravel comes with it No more
From 1970-01-01 08:00:00
0
0
0
Why thinkphp has better performance than laravel?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template