如何只重写Nginx中的特定目录?
公用文件夹包含静态html文件(我不想在这里重写),重写仪表板目录的URL
示例:
公共 -Index.html -page2.html -pahe3.html -dashboard< - 要重写的目录
最后,我们可以像这样访问网址: http://example.com/index.html或http://example.com/dashboard/home
我尝试添加此内容:
listen 80;
server_name example.com www.example.com;
index index.php index.html index.htm;
set $root_path '/usr/share/nginx/html';
root $root_path;
location /dashboard {
index index.php index.html index.htm;
set $root_path '/usr/share/nginx/html/dashboard/public';
root $root_path;
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index /index.php;
include /etc/nginx/fastcgi_params;
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;
}
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
root $root_path;
}
location ~ /\.ht {
deny all;
}
}
try_files $uri $uri/ @rewrite;
location @rewrite {
rewrite ^/(.*)$ /index.php?_url=/$1;
}
但不行。它显示找不到页面