Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
hofmann
Active Contributor
5,206

In this blog I will focus on the Web Dispatcher 7.2 together with the portal and the new feature of manipulating URLs by making use of the HTTP handlers. I will focus on the redirect URL manipulation and therefore on the redirect handler (SAP Help).

The redirect handler forwards the HTTP request from the browser to another location (HTTP redirect). Redirecting the browser was already possible in earlier versions of Web Dispatcher (the URL prefixes the ICM uses for the redirect are determined by the icm/HTTP/ redirect_<xx> parameter), but in 7.2 it gained a new feature: now you can define the HTTP code. In versions < 7.2 the browser requested a resource and the Web Dispatcher sent back a HTTP 302 or 307, depending on the HTTP protocol used by the browser. If it is a HTTP 1.0 request, the answer is a 302, if it is HTTP 1.1 (keep alive) it is 307.

As this serves the basic needs of applying the redirect, it isn’t a permanent redirect. Temporary or permanent redirects are more or less treated equally by browsers. A Google search revealed that it looks like Google Chrome, Firefox 3.5 and IE9 are may cache 301 (see here  (http://en.wikipedia.org/wiki/HTTP_301) for general information on 301 cache) while other browsers will look up the URL with every request.


To proof that the Web Dispatcher is not a full reverse proxy only requests can be manipulated. As the name of the operation suggests, only the request and not the response are treated by Web Dispatcher. The Syntax for the redirect handler is:

RegRedirectUrl / http://server.domain:8080/default.html ; (CODE=permanent)

Where the code value can be: permanent, temp or seeother.

Example

Lets say you have stored a document in your KM and changed it (name, location), but you cannot change all the links that refer it (or create a link in the KM). The original document is stored here:

http://server:port/irj/go/km/docs/documents/Test/original.txt

and the new one here:

http://server:port/irj/go/km/docs/documents/Test/newfile.txt

In the KM you can create a link from the original location to the new location, but this implies that you create a link in the KM. Letting the Web Dispatcher handle the redirect means that the actual request to the old file never will reach the KM and portal. The Web Dispatcher will intercept the request and send back the redirect. In Web Dispatcher 7.0 the redirect rule would be:

icm/HTTP/redirect_0 = PREFIX=/irj/go/km/docs/documents/Test/original.txt, TO=/irj/go/km/docs/documents/Test/newfile.txt

When the user accesses the file the Web Dispatcher and the browser will treat the request as shown here:

To change the 307 to a 301 it is necessary to make use of modification actions. Modification actions allow a complex alteration of HTTP requests / headers. For modifying the request to be a permanent redirect, you need to follow the steps outlined here. The main steps are:

1.

Create an action file. This file contains the (regular) expression that should be applied. A For my example I named the file actionfile.txt and the content is just 1 line:

RegRedirectUrl ^/irj/go/km/docs/documents/Test/original.txt /irj/go/km/docs/documents/Test/newfile.txt  (CODE=permanent)

2.

Activate the modification actions in the profile file of the Web Dispatcher by setting the parameter icm/HTTP/mod_<xx>

In my case, the syntax is:

icm/HTTP/mod_0 = PREFIX=/,FILE=actionfile.txt

When the users tries to access the original.txt file the Web Dispatcher sends back a 301 and the browser requests the new file:

Result

How about cache?

1st request: Both files are access the first time and therefore loaded.

2nd request: The 301 gets called again, while the newfile.txt is loaded from cache.

https://weblogs.sdn.sap.com/weblogs/images/251875405/301image4.jpg|height=34|alt=image|width=396|src...!


4 Comments
Labels in this area