实现 http://127.0.0.1/$URI 重写为 http://127.0.0.1/chrome/$URI
1、配置文件代码:
server {
root /usr/share/nginx/www;
index index.php index.html index.htm;
listen 80;
server_name localhost;
location / {
#如果是火狐浏览器访问
if ($http_user_agent ~* 'firefox') {
rewrite ^(.*) /chrome/$1 last;
}
}
location /chrome {
root /usr/share/nginx/www;
index index.html;
}
#错误日志
error_log /usr/share/nginx/logs/error.log error;
}
2、目录结构
3、访问结果
http://127.0.0.1/m ===》http://127.0.0.1/chrome/m
4、 如果有什么问题,可以查看错误日志 tail -f /usr/share/nginx/logs error.log