添加nginx虚拟主机

时间:2016-02-03 11:45:37

标签: regex nginx

我目前为用户提供了alex / available位置:

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

我需要

  
      
  1. 添加新位置/alexandru;
  2.   
  3. 永久重定向从example.com/alexexample.com/alex/
  4.   

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

1 个答案:

答案 0 :(得分:1)

快速而肮脏的解决方案:

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