我有一个像下面这样的配置文件:
服务器 {
听 80;
server_name 本地主机;
#charset utf-8;
根 html/laravel/public;
索引 index.html 索引.php;
#如果没有索引文件则浏览文件夹
自动索引开启;
# 强制不 www
if ($host ~* ^www\.(.*))
{
设置 $host_without_www $1;
重写 ^/(.*)$ $scheme://$host_without_www/$1 永久;
}
# 直接提供静态文件
位置 ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log 关闭;
#expires max;
}
# 删除尾部斜杠(防止 SEO 重复内容问题)
if (!-d $request_filename)
{
重写 ^/(.+)/$ /$1 永久;
}
# 规范化 codeigniter url 端点
# 如果您的默认控制器不是“欢迎”,您应该更改以下内容
# if ($request_uri ~* ^(/lobby(/index)?|/index(.php)?)/?$)
# {
# 重写 ^(.*)$ / 永久;
# }
# 从所有控制器中删除尾随“索引”
if ($request_uri ~* index/?$)
{
重写 ^/(.*)/index/?$ /$1 永久;
}
# 除非请求是针对有效文件(图像、js、css 等),否则发送到引导程序
if (!-e $request_filename)
{
最后重写 ^/(.*)$ /index.php?/$1;
休息;
}
# 将服务器错误页面重定向到静态页面 /50x.html
#
error_page 500 502 503 504 /50x.html;
位置 = /50x.html {
根html;
}
位置/后端/ {
根/html/前端;
}
位置 ~ \.php$ {
包括 fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
包括 fastcgi_params;
}
位置 ~ /\.ht {
全部否认;
}
# 全部捕获
#error_page 404 /index.php;
# 位置 ~ \.php$ {
# try_files $uri =404;
# fastcgi_pass unix:/tmp/php.socket;
# fastcgi_index index.php;
# #include fastcgi_params;
# 包括 /home/tamer/code/nginx/fastcgi_params;
# }
# access_log /home/tamer/code/laravel/storage/logs.access.log;
#error_log /home/tamer/code/laravel/storage/logs.error.log;
}
我必须将根文件夹更改html/backend为任何带有$host/backend/. 加载页面的所有规则必须相同,只有根文件夹必须更改。
我怎样才能做到这一点?