iRule to Rewrite request and response

Hello I need help in coming up with an iRule for the below scenario.

http://mainapp.abc.com is the url for the main application.

http://about.mainapp.abc.com and http://contact.mainapp.abc.com are 2 diff sub applications.

The user will enter http://mainapp.abc.com/about or http://mainapp.abc.com/contact to access these sub applications.

So what I am looking for is -

User will enter - http://mainapp.abc.com/about The url should be rewritten to the back-end server as http://about.mainapp.abc.com when the page is returned to the client he should see http://mainapp.abc.com/about

How do I go about accomplishing this and thank you for your help and time.

Hi,

Did you try to set your stuff with an rewrite profile?

you can rewrite request and response (more simple for maintain and manage):

Regards,