Nginx resource oriented CSS JS path problem

Source: Internet
Author: User

Do the project today, learn to learn Nginx found is also good, speed can also, but CSS JS is not used, the original Nginx configuration requires different types of file configuration rules, it is very depressing, but think also is very reasonable. When the problem is solved, post the configuration to share.

#user nobody;

Worker_processes 1;

Error_log Logs/error.log;

PID Logs/nginx.pid;

Events {

Worker_connections 1024;

}

HTTP {

Include Mime.types;

Default_type Application/octet-stream;

#log_format Main ' $remote _addr-$remote _user [$time _local] "$request"

# ' $status $body _bytes_sent ' $http _referer '

# ' $http _user_agent ', ' $http _x_forwarded_for ';

Access_log Logs/access.log;

Sendfile on;

#tcp_nopush on;

#keepalive_timeout 0;

Keepalive_timeout 65;

#gzip on;

server {

Listen 8081 default;

server_name localhost;

CharSet Utf-8;

Location/{

Index index.php;

if (!-e $request _filename) {

#rewrite ^/myapp/(. *. ( css|js|jpg|gif|png)) $/$1 last;

Rewrite ^/(. *) $/index.php/$1;

Break

}

}

Location ~. +.php ($|/) {

Set $script $uri;

Set $path _info "/";

if ($uri ~ "^ (. +.php) (/.+)") {

Set $script $;

Set $path _info $;

}

Include fcgi.conf;

Root D:apache2.2htdocsmyblog;

Fastcgi_pass 127.0.0.1:9000;

Fastcgi_index index.php? if_rewrite=1;

Fastcgi_param path_info $path _info;

Fastcgi_param script_filename $document _root/$script;

Fastcgi_param Script_name $script;

}

Location ~*. (JPG|GIF|PNG|JS|CSS) $ {

Root D:apache2.2htdocsmyblog;

if (-f $request _filename) {

Expires Max;

Break

}

}

}

}

Related Article

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.