Inspired by the use of # To maintain the Page Status in ajax, this javascript + xml SharpRewriter is written to implement url redirection in a pure html environment.
Source code download: http://files.cnblogs.com/cncxz/SharpRewriter1.0.rar
Test procedure:
1. Place the index.htm, SharpRewriter1.0.js, and config. xml files in any directory of IIS.
2. Assume the SharpRewriter directory of the port 80 site
Access [http: // yourIP/SharpRewriter/], will switch to http://www.net.cn
Access [http: // 127.0.0.1/SharpRewriter/], will switch to http://www.126.com
Access [http: // 127.0.0.1/SharpRewriter/# gmail], will turn to the http://www.gmail.com
Access [http: // 127.0.0.1/SharpRewriter/#163], will switch to http://mail.163.com
Access [http: // localhost/SharpRewriter/], will switch to http://www.google.com
Access [http: // localhost/SharpRewriter/# baidu], will switch to http://www.baidu.com
Access [http: // localhost/SharpRewriter/# zhongsou], will switch to http://www.zhongsou.com
3. Of course, you can create a new site pointing to the SharpRewriter folder. Assume that port 90 is used.
Access [http: // yourIP: 90], will switch to http://www.net.cn
Access [http: // 127.0.0.1: 90], will turn to the http://www.126.com
Access [http: // 127.0.0.1: 90/# gmail], will turn to the http://www.gmail.com
Access [http: // 127.0.0.1: 90/#163], will turn to the http://mail.163.com
Access [http: // localhost: 90/], will turn to the http://www.google.com
Access [http: // localhost: 90/# baidu], will turn to the http://www.baidu.com
Access [http: // localhost: 90/# zhongsou], will switch to http://www.zhongsou.com
File description
1. SharpRewriter1.0.js is the javascript Implementation of url redirection.
2. config. xml is the redirection rule configuration file. You can modify or add the HostItem and SharpItem nodes (Note: all the letters in the HostName and SharpName values must be in lower case ).
32.16index.htm is the call file, var mySR = new SharpRewriter (); and var mySR = new SharpRewriter ("config. xml ") is two ways to instantiate SharpRewriter. The first xml configuration file uses the default path (config. xml), the second is the custom path. Let's take a look at the code.
Some adjustments may be made after the code is released. Please check the latest version on your blog.