【问题标题】:Rewrite NGINX URL Location?重写 NGINX URL 位置?
【发布时间】:2014-12-06 18:10:51
【问题描述】:

我想在我的服务器上使用 Baikal 和 NGINX。 baikal的index.php在/baikal/html

以下配置的请求适用于此 url:

https://www.mydomain.com:8001/baikal/html

我如何更改 NGINX 配置

https://www.mydomain.com:8001/baikal

被重定向到https://www.mydomain.com:8001/baikal/html

这是我的 NGINX 配置:

server {
        listen 8001;

        ssl on; # <-------------------------------------------- SSL
        ssl_certificate /etc/nginx/ssl/seahub.crt; # <--------- SSL
        ssl_certificate_key /etc/nginx/ssl/seahub.key; # <----- SSL

        server_name confile.no-ip.biz; #.tld; # <----------------- CHANGE THIS

        root /usr/share/nginx/www;
        index index.html index.htm index.php;

        rewrite ^/.well-known/caldav /cal.php redirect;
        rewrite ^/.well-known/carddav /card.php redirect;

        location / {


        location ~ ^(.+\.php)(.*) {
                try_files $fastcgi_script_name =404;
                fastcgi_split_path_info ^(.+\.php)(.*)$;

                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_param  PATH_INFO        $fastcgi_path_info;
                fastcgi_index index.php;
                include fastcgi_params;
        }

        charset utf-8;

        location ~ /(\.ht|Core|Specific) {
                deny all;
                return 404;
        }

        }

}

【问题讨论】:

    标签: php html redirect nginx https


    【解决方案1】:

    首先,您不应该在另一个location 中包含location。确保它们都是分开的。

    接下来,实际创建重写:

    location = /baikal {
      return 301 /baikal/html
    }
    

    应该可以解决问题。

    【讨论】:

      猜你喜欢
      • 2013-12-16
      • 2020-05-26
      • 1970-01-01
      • 2016-02-14
      • 2012-04-16
      • 2016-05-30
      • 1970-01-01
      • 1970-01-01
      • 2018-06-21
      相关资源
      最近更新 更多