thinkphp Nginx The following perfect configuration to resolve 404 File not Found

Source: Internet
Author: User
server {
Listen 80;
server_name Thinkphp.lo;
root/var/www;
Index index.html index.htm index.php;

Error_page 404/404.html;
Location =/404.html {
Return 404 ' Sorry, File not found! ';
}
Error_page 502 503 504/50x.html;
Location =/50x.html {
root/usr/share/nginx/html; # Windows user replaces this directory
}

Location/{
Try_files $uri @rewrite;
}

Location @rewrite {
Set $static 0;
if ($uri ~ \. ( CSS|JS|JPG|JPEG|PNG|GIF|ICO|WOFF|EOT|SVG|CSS\.MAP|MIN\.MAP) $) {
Set $static 1;
}

if ($static = 0) {
Rewrite ^/(. *) $/index.php?s=/$1;
}

}

Location ~/uploads/.*\.php$ {
Deny all;
}

Location ~ \.php/{
if ($request _uri ~ ^ (. +\.php) (/.+?) ($|\?)) { }
Fastcgi_pass 127.0.0.1:9000;
Include Fastcgi_params;
Fastcgi_param Script_name $;
Fastcgi_param Path_info $;
Fastcgi_param script_filename $document _root$1;
}

Location ~ \.php$ {
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Include Fastcgi_params;
}

Location ~/\.ht {
Deny all;
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.