Nginx Access CSS JS pictures and other static resources, reported 404 or cannot be directed to access to

Source: Internet
Author: User

After the configuration of Nginx, the PHP project put up, found that Css,js and pictures all access, has been redirected to the root directory to perform index.php, depressed on-line search for a half-day, the original different suffix file access to the nginx.conf in the Declaration of rules, such as the next,

Location ~*. (Jpg|gif|png|js|css) $ {root E:\Project\PHP\mobao; if (-F $request _filename) {Expires max;break;}}

In the location ~ \.php$ front with the above rules, restart Nginx, refresh the page, Access success!!!

       Location ~*. (jpg|gif|png|js| CSS) $ {            root E:\Project\PHP\mobao;              if (-F $request _filename) {                expires max;                  Break  ;            }    }                ~ \.php$ {            #root           html;            Fastcgi_pass   127.0. 0.1:9009;            Fastcgi_index  index.php;            ...

If it is only the root directory home index.php can access, other page 404, please see my other blog post http://www.cnblogs.com/cxscode/p/6978428.html

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Nginx access CSS JS pictures and other static resources, reported 404 or cannot be directed to access to

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.