【问题标题】:add nginx virtual host添加 nginx 虚拟主机
【发布时间】:2016-05-12 14:21:56
【问题描述】:

我目前有位置 alex/ 可供用户使用:

location ~* ^/alex/ {
rewrite ^/alex(/.*)$ $1 break;

我需要

  1. 添加一个新位置,/alexandru;
  2. 进行从example.com/alex 到example.com/alex/ 的永久重定向。

我已经使用location /alexandru 创建了新位置并且效果很好,但是当我尝试使用rewrite ^/alex(.*)/$ /$1 break; 进行永久重定向时它失败了。

【问题讨论】:

标签: regex nginx


【解决方案1】:

快速而肮脏的解决方案:

location /alex {
   rewrite ^/alex(.*) http://$server_name/url_to/alexandru$1 permanent;
 }

【讨论】:

    猜你喜欢
    • 2014-11-12
    • 2013-09-18
    • 2012-07-08
    • 2017-02-27
    • 2016-09-19
    • 2020-09-29
    • 2014-04-22
    • 2017-05-05
    相关资源
    最近更新 更多