Rewriting & redirecting : Example: Rewriting URLs using regular expressions
 
Example: Rewriting URLs using regular expressions
Example.edu is a large university. Professors use a mixture of WordPress and Movable Type software for their course web pages to keep students updated. In addition, the campus bookstore and software store use custom shopping cart software. The URLs of these web applications contain clues about the underlying vendors, databases and scripting languages.
The university is a frequent target of attacks because it is a large organization with many mobile users and guests, and an Internet connection with large bandwidth. Its network administrators want to hide the underlying technology to make it more difficult for attackers to craft platform-specific attacks. Example.edu also wants to make clients’ bookmarked URLs more permanent, so that clients will not need to repair them if the university switches software vendors.
Because it has so many URLs, the university uses regular expressions to rewrite sets of similar URLs, rather than configuring rewrites for each URL individually. More specific URL rewrite rules are selected first in the URL rewriting group, before general ones, due to the affects of the matching order on which each rewrite rule is applied.
Table 45: Example URL rewrites using regular expressions
Regular Expression in URL match condition
Example URL in client’s request
Result
^/cgi/python/ustore/payment.html$
/store/checkout
/cgi/python/ustore/payment.html
/store/checkout
^/ustore*$
/store/view
/ustore/viewItem.asp?id=1&img=2
/store/view
/Wordpress/(.*)
/blog/$0
/wordpress/10/11/24
/blog/10/11/24
/(.*)\.xml
/$0
/index.xml
/index
See also
Example: HTTP-to-HTTPS redirect
Example: Rewriting URLs using variables
Rewriting & redirecting
Regular expression syntax
What are back-references?
Cookbook regular expressions