SharpRewriter: using javascript + xml technology # implementing url redirection

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.