sni*_*tko 3 configuration redirect nginx
我要关闭一个网站,我需要nginx将所有用户重定向到根目录,而不仅仅是在所有网站URL上向他们显示相同的页面。
现在我有这个:
server {
listen 80;
root /var/www/mysite;
rewrite ^.*$ /index.html last;
}
Run Code Online (Sandbox Code Playgroud)
但是,这不会重定向,而是index.html在各处显示内容。如何进行重定向,以便mysite.com/somepage重定向到mysite.com显示index.html页的页面?
以下应该做您想要的:
server {
listen 80;
root /var/www/mysite;
location = / { try_files /index.html = 404;}
location / { rewrite ^ / permanent; }
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5342 次 |
| 最近记录: |