想用nginx实现url重写的功能,求教该怎么样写配置?
想在浏览器地址栏输入localhost:8080/ProjectName/admin,按回车键后会自动跳转到localhost:8080/ProjectName/admi...
想在浏览器地址栏输入localhost:8080/ProjectName/admin,按回车键后会自动跳转到localhost:8080/ProjectName/admin/login.html登录界面,该怎么写nignx的配置文件?
展开
1个回答
展开全部
server {
listen 8080;
server_name localhost;
location / {
root ProjectName/admin;
index index.html;
}
}
server {
listen 8080;
server_name localhost;
if ( $http_host ~* "^(.*)localhost:8080$") {
set $login login.index;
rewrite ^(.*) http://localhost:8080/ProjectName/admin/$login break;
}
}
listen 8080;
server_name localhost;
location / {
root ProjectName/admin;
index index.html;
}
}
server {
listen 8080;
server_name localhost;
if ( $http_host ~* "^(.*)localhost:8080$") {
set $login login.index;
rewrite ^(.*) http://localhost:8080/ProjectName/admin/$login break;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询