Forum Discussion
Sorin_Rusnac_86
Nimbostratus
Mar 12, 2008iRule to overwrite Page Extension help!
Hi -
Hoping somebody can help me is there a sample or code i can use to overwrite file extenstions on pages is this possible?
For example what I want the iRULE to do is as follows:
Example: ‘http://ourdomain.com/JDE/TaskExplorer/somelink.JSP’ gets rewritten to ‘http://ourdomain.com/JDE/TaskExplorer/somelink.jsp’
So it will rewrite uppercase JSP to lowercase jsp.
Thanks
- Nicolas_Menant
Employee
hi, - hoolio
Cirrostratus
In addition to nmenant's example, here are a couple more options:when HTTP_REQUEST { Get the path (/path/to/file.ext) Use URI::basename to get the filename and extension (file.ext). Use getfield to split on the period, getting only the extension (ext). Prepend a period back to make the string more specific. set file_extension .[getfield [URI::basename [HTTP::path]] . 2 ] Log the parsed file extension log local0. "Original file extension: $file_extension" For two to four letter capitalized extensions, update the path with the lower case extension. switch -glob $file_extension { .[A-Z][A-Z] - .[A-Z][A-Z][A-Z] - .[A-Z][A-Z][A-Z][A-Z] { Set extension to lowercase set file_extension_lowered [string tolower $file_extension] Update the path by replacing the original file extension with the lowered case version HTTP::path [string map "$file_extension $file_extension_lowered" [HTTP::path]] Log the updated path (this should be removed when you're done testing). log local0. "Updated path: [string map "$file_extension $file_extension_lowered" [HTTP::path]]" } } }
when HTTP_REQUEST { HTTP::path [string map -nocase {.jsp .jsp} [HTTP::path]] }
- Sorin_Rusnac_86
Nimbostratus
Thanks guys for all the help, I really appreciate the quick replies your help is much appreciated.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects