我正在运行nginx v 1.0.4,我们正在尝试执行以下操作:location ~ ^/${rewrite ?^.*$?/index.html ?last;}基本上:如果用户到达默认域http://www.foo.com或http://www.foo.com/将其重定向到http://www.foo.com/index...
我正在运行nginx v 1.0.4,我们正在尝试执行以下操作:
location ~ ^/${
rewrite ?^.*$?/index.html ?last;
}
基本上:如果用户到达默认域http://www.foo.com或http://www.foo.com/将其重定向到http://www.foo.com/index.html
当我将其添加到我的conf文件中时,我得到以下内容:
在/etc/nginx/myconf.conf中启动nginx:nginx:[emerg] unknown指令“”
提前致谢.
解决方法:
您可以在没有位置的情况下使用重写功能
rewrite ^/$ /index.html last;
或永久重定向
rewrite ^/$ /index.html permanent;
用参数重写,例如http://www.foo.com/?param=value – > http://www.foo.com/index.html?param=value
rewrite ^/(\?.*)?$ /index.html$1 permanent;
本文标题为:nginx位置修复:重定向到index.html
基础教程推荐
- 关于html选择框创建占位符的问题 2022-09-20
- Ajax实现表格中信息不刷新页面进行更新数据 2023-02-22
- 活到老学到老学习AJAX跨域(三) 2022-12-18
- Ajax上传图片及上传前先预览功能实例代码 2023-02-14
- ajax中设置contentType: "application/json"的作用 2023-02-14
- vue-vuex-getters的基本使用 2023-10-08
- ajax异步实现文件分片上传实例代码 2023-02-23
- 利用ajax+php实现商品价格计算 2023-02-23
- HTML5添加禁止缩放功能 2022-09-16
- vue解决跨域问题 2023-10-08
