简体   繁体   中英

Redirect a specific request to another domain

I am making a private server for a game, and I need to redirect all requests from http://crossfire.z8games.com/ to (let's say) http://cfire.v1k.me/ but only while the redirection program is running. I need some suggestions and what language this is best done (in java/c++, etc.)

I don't want to hex edit program, because I want the user to easily switch between my server and the original server.

So, again, I want some suggestions and code examples on how to simply redirect xxx.xx to yyy.yy with a simple application without modifying the hosts file.

You can use Java's HttpURLConnection to check for an error when connecting to the first url. If an error happens, then you try the second one.

Here's an example that shows how to connect to one url. In the catch blocks, that's where you should try to connect to the second url.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM