Answer the question
In order to leave comments, you need to log in
Nginx, is it possible to "give away" css and js scripts from another directory?
Nginx is on the local machine, purely for development purposes, not production.
Work is underway on two projects, both are in /usr/share/nginx/html
, i.e.:
Project 1 lies: в /usr/share/nginx/html/project1
Project 2 lies: в /usr/share/nginx/html/project2
and are available by http://localhost/project1
and http://localhost/project2
respectively.
js scripts and css are located in the root of the projects projectN/js и projectN/css
simple config:
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html index.htm index.php;
location ~* \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location /project1/ {
try_files $uri $uri/ /project1/back/index.php;
}
location /project2/ {
try_files $uri $uri/ /project2/index.php;
}
}
http://localhost/project1/page1
, html is returned, in which the styles are connected like this: <link href="css/styles.css" rel="stylesheet">
http://localhost/project1/page1/css/styles.css
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question