我正在运行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


基础教程推荐
- ECSHOP中实现ajax弹窗登录功能 2023-01-31
- vue文档熟读之---深入了解组件 2023-10-08
- Ajax提交表单页面刷新很快的解决方法 2023-01-26
- Vue+elementui防止重复提交 2023-10-08
- 深入探讨CSS中字体元素 2022-10-16
- Ajax实现异步加载数据 2023-02-23
- 使用Ajax方法实现Form表单的提交及注意事项 2023-02-14
- 没时间学 Vue (2) 2023-10-08
- Ajax实现动态加载组合框的实例代码 2023-02-14
- vue-vuex-mutations的基本使用 2023-10-08