配置一个vhost,开启rewrite隐藏index.php,页面能正常访问
但是发现css、js、jpg等静态资源路径有问题:变成了域名+文件绝对路径
http://www.guestbook-dev.com/Users/haotao/www/Study/guestbook-dev/Public/asset/vendor/bootstrap3/css/bootstrap.min.cs
请教一下该如何配置才能让静态资源正确访问呢?
server {
listen 80;
server_name www.guestbook-dev.com;
set $root_path '/Users/haotao/www/Study/guestbook-dev/Public';
root $root_path;
index index.php index.html index.htm;
try_files $uri $uri/ @rewrite;
location @rewrite {
rewrite ^/(.*)$ /index.php?_url=/$1;
}
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index /index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
root $root_path;
}
location ~ /\.ht {
deny all;
}
}
RISEBY
墨色风雨
肥皂起泡泡
江户川乱折腾