laravel如何設定nginx偽靜態?

來源:互聯網
上載者:User
按照官網設定的直接不解析網頁變成下載了,試了網上的很多版本也沒用。
用的是LNMP一鍵安裝環境。

我的vhost配置資訊:

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;    }

回複內容:

按照官網設定的直接不解析網頁變成下載了,試了網上的很多版本也沒用。
用的是LNMP一鍵安裝環境。

我的vhost配置資訊:

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;    }

我的配置是這樣的:

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;}
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.