nginx url别名不起作用

时间:2018-02-26 16:37:09

标签: nginx alias

我在nginx中尝试了URL alias的多种变体,但似乎没有任何效果。 domain.com/store-trans/index.html有效,但别名domain.com/retail/12/store不适用

server {

    listen   80;
    listen   443 default ssl;
    root /var/www/html;

    include /etc/nginx/conf.d/_redirects;
    port_in_redirect off;
    proxy_redirect off;
    client_max_body_size 60m;

    location / {
        try_files $uri /index.php?$query_string; # For Drupal >= 7
    }

## New Alias 
    location ~ ^/store-trans/index.html {
        alias /retail/12/store;
    }

1 个答案:

答案 0 :(得分:0)

尝试将alias更改为return

location ~ ^/store-trans/index.html { return 301 /retail/12/store; }