首頁  >  問答  >  主體

url-rewrite - Nginx 中rewrite url路徑位址有問題

系統中有一個需求是將某一段url連結位址轉鏈到另外一段位址,model類似於將
localhost/wish/1234.jhtml自動前往localhost/community/detail/1234.jhtml。

目前Nginx我的設定寫法是

location ~ ^/wish/$ {
rewrite ^/(.*)$  ^/community/detail/$1 permanent;
}

但是運行後系統提示404...請問我這句該如何改呢?非常感謝!

巴扎黑巴扎黑2712 天前551

全部回覆(1)我來回復

  • PHP中文网

    PHP中文网2017-05-16 17:28:14

    設定檔寫錯了,按下面的寫就行,不用放在location下。
    rewrite ^/wish/(.*).jhtml$ /community/detail/.jhtml permanent;

    回覆
    0
  • 取消回覆