I'm working on dynamically adding a script block using an IIS
URL Rewrite Rule
(outbound). The script block should begin right after the HTML
head
tag. It works as intended. The only problem is I'd like to place the script block on a new and possibly indent. I'd like to add a carriage return
and line feed
to the Action Rewrite Value
.
Here is what I have thus far:
After URL Rewrite processes, the source file resembles:
<head><script type="text/javascript" src="webanalytics.js"></script>
<title>Test Page</title>
<meta name="description" content="Test Page">
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
</head>
What I desire is this:
<head>
<script type="text/javascript" src="webanalytics.js"></script>
<title>Test Page</title>
<meta name="description" content="Test Page">
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
</head>
Can this be done with the IIS URL Rewrite Rule module?
Thank you for your help in advance.
Thank you for the feedback.
I did manage to get the formatting/indenting how I preferred. Yes, nobody reads the source code but the browser engine. But I prefer to maintain format consistency for testing and troubleshooting client-side issues.
Pattern:
(<head.*?>(\s*))
(Action) Value:
{R:1}<script type="text/javascript" src="webanalytics.js"></script>{R:2}