How do I use the URL re-writing functionality of the web content portlet?

Submitted: January 31, 2007
How do I use the URL re-writing functionality of the web content portlet?

URL re-writing will help portal administrators create qualified links to content within the portlet on the fly without changing the provided content. The idea would be to change a relative source into a fully qualified one.

 

File system source:

If you pull from a file system on the Academus server you will have to serve the images through Apache. You will have to specify the sub-directory that the content is contained in under the webapps directory within the portal.  Therefore you could do a pattern match like the following.

 

Example:

<url-rewriting>

<pattern match-type="starts-with">

<match>images/<match>

<replace-with>/WCM/project/images/<replace-with>

</pattern>

</url-rewriting>

 

Thus, if the src attribute of an <img> tag is "images/myimage.jpg" it will be re-written to /WCM/project/images/myimage.jpg" or from a fully qualified URL perspective, http://myportal.myschool.edu/WCM/project/images/myimage.jpg".

 

URL source:

If a website uses relative paths for images you could re-write them to be fully qualified. The example above still stands, you can just replace "/WCM/project/images/" with “http://www.mycompany.com/images/”.  This would put http://www.mycompany.edu/images/myimage.jpg.

 

Example:

<url-rewriting>

<pattern match-type="starts-with">

<match>images/<match>

<replace-with> http://www.mycompany.com/images<replace-with>

</pattern>

</url-rewriting>

 

 

Note: If the URL you point the portlet too already has fully qualified src's and href's you don't have to do re-writing.

 

Currently, starts-with is the only match-type supported. In the future ends-with and

contains will be implemented. Keep in mind that you can have as many re-write rules as you choose and they will be performed sequentially.

 

Note: The re-write will work on the following attributes in the tags

listed beneath them.

 

href

<a>

src

<img>

<bgsound>

<embed>

<input> (type="image")

<script>