Nginx URL重写更改URL [英] Nginx URL rewrite changes URL

查看:1940
本文介绍了Nginx URL重写更改URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要重定向nginx中的URL.我的规则看起来像这样,实际上导致浏览器明显地更改了URL,这不是预期的.

I need to redirect a URL in nginx. My rule looks like this which actually causes the browser to visibly change the URL, which is not what is expected.

   location / {
      rewrite ^/dentists/bangalore/indiranagar/$ http://abc.com/doctorsInArea.htm?cID=bangalore&aID=indiranagar break;
    }

我在这里阅读了另一个问题 nginx重写而未更改URL ,告诉我删除http部分.我尝试过

I read another question here nginx rewrite WITHOUT change url which tells me to remove the http part . I tried

    location / {
      rewrite ^/dentists/bangalore/indiranagar/$ /doctorsInArea.htm?cID=bangalore&aID=indiranagar break;
    }

即使 http://abc.com/当从浏览器中点击doctorsInArea.htm?cID = bangalore& aID = indiranagar 时,效果很好.对这个问题的任何见解都会得到赞赏.

This one throws a 404 even though http://abc.com/doctorsInArea.htm?cID=bangalore&aID=indiranagar works fine when hit from the browser. Any insights on the problem would be apprreciated.

推荐答案

我通过使用以下命令使它正常工作.

I got it working by using the following.

location / {
      rewrite "/dentists/bangalore/indiranagar/" /doctorsInArea.htm?cID=bangalore&aID=indiranagar last;
    }

谢谢!

这篇关于Nginx URL重写更改URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆