search

Home  >  Q&A  >  body text

url-rewrite - There is a problem with the rewrite url path address in Nginx

There is a requirement in the system to transfer a certain url link address to another address. The model is similar to
localhost/wish/1234.jhtml automatically goes to localhost/community/detail/1234.jhtml.

Currently my configuration writing method for Nginx is

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

But after running, the system prompts 404...How should I change this sentence? Thank you so much!

巴扎黑巴扎黑2757 days ago582

reply all(1)I'll reply

  • PHP中文网

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

    The configuration file is written incorrectly. Just write it as below. There is no need to put it under location.
    rewrite ^/wish/(.*).jhtml$ /community/detail/.jhtml permanent;

    reply
    0
  • Cancelreply