开发者

Using 3xx codes to perform redirect for directory level resources

I have hosted a local server on my system on port 80. And I have few other local servers running on port 8080/8081/8082.. And I want to redirect by requests from port 80 to these ports based on the directory they access.

So for example if request is like http:// 127.0.0.1/test1/... I want request to be redirected to http:// 127.0.0.1:8080/test1/....

Is there a way in which I can just return 301 once and then browser understands that all the requests 开发者_如何学JAVAwith http:// 127.0.0.1/test1/ prefix all automatically should be redirected to new URL. I do not want to send redirect call for every resource within test1 folder.


There is no way to do what you are describing using 3xx HTTP response codes. You do however, have several options:

  1. Use a rewrite module
  2. Create a relay, to simply connect the client to the correct server
  3. Setup your server to send a 301 code for every url that starts with a certain path (test1, for example).

You'll need to provide more information about what type of servers you're using to get a more specific answer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜