outboundRule for dynamically generated content using the IIS Rewrite module - url-rewriting

I am trying to write the outbound rules for URLs using the IIS Rewrite module. It is working fine for the static URLs, however, the outbound rule is not applying on the dynamically generaged URLs using the script. In some places in the application, the anchor tags with href () are generating using the jQuery script. The outbound rules are not applying on these type of URLs.
I am using the below pre condition to include the script files, still not working.
<preCondition name="ResponseIsTextAnything">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/(.+)" />
</preCondition>
Appreciate your expertise suggestions here. Thank you.

Related

Source Urls having '#' in them (anchor links) are not redirecting

I currently have a redirect filter working on an old site with 100+ html pages (static site). However, the remaining API docs (200+ pages) which all have a "#" in them are not redirecting. The original site was implemented as an SPA and hence had anchor links for all API docs; the target site have clean urls.
Snippet of UrlRedirectFilter
<rule>
<name>Delete Transactions</name>
<from>^/api/#create-transaction-deletion$</from>
<to last="true" type="redirect">https://baseurl/apis/Transaction/deleteTransactions</to>
<rule>
<name>Payment Charge</name>
<from>^/api/#paymentcharge$</from>
<to last="true" type="redirect">https://baseurl/apis/Payment%20Method/PaymentMethodCharge/</to>
Is there a hidden rule in url tuckey filter that discards anchor links? Is there a regex I need to be aware of? If none of the regex patterns work on the filter, what's the best way to move forward by extending urlrewriteFilter? Thanks!

Routing rules in web service

I have a configuration file. It contains RouteRules and in this element, you add Rules within the Rules tag using the add. Within the add element, it has a From parameter with a certificate line similar to the following:
<RoutingRules>
<Rules>
<add .... From="CN=*.domain.com, O=myorg, etc." />
</Rules>
</RoutingRules
This is the line I think I can update to include https only, but I am not sure.
From="CN=*.domain.com, O=myorg, etc."
Can I configure this rule to only allow https? I have seen posts that say in IIS you make it accept only https, but this does not seem to be what the customer wants. They believe I can update the config file and enable only https traffic.

URL Forwarding based on request parameters

I am using UrlRewriteFilter from http://www.tuckey.org/urlrewrite/. Mainly I am trying to get the following URL http://domain/application/?param=value to redirect to http://domain/application/?another_param=another_value (simply replacing the request param).
Below are my rule configuration that dosen't seem to work
<rule>
<from>^(.*?param=value)$</from>
<to type="forward">%{context-path}?another_param=another value</to>
</rule>
I have tried several other variations but that didn't seem to work either. any light shed on this issue would be much appreciated
I have been able to resolve the issue using the rule below
<rule>
<name>Selective redirect example redirect</name>
<condition type="parameter" name="param" operator="equal">value</condition>
<to type="forward">?another_param=another_value</to>
</rule>
The key to the answer here is using the conditions rather than depending on the rule to capture the request, in my case I needed only to apply the rule when a certain param value is met. The second part of the answer is removing the <from> tag, and hence all the requests that fulfill the condition will be redirected to the same source page.
Finally, below are the links that were most useful in my search for the answer:
URLRewriteFilter Examples page
The Developer's Tidbits: Tuckey URLRewrite How-To
StackOverflow post: URL Rewrite Filter not working with query parameters containing special characters

Is their an equivalent of a Java servlet in Classic ASP or how would I simulate one?

I'm assigned the task of implementing session checking for a Classic ASP application. I don't want to include session checking on every single page.
I'd rather use something that's akin to a servlet or servlet filter in Java. The problem is I don't know of any implementation in Classic ASP which approximates this effect. Must I check for an existing session in each and every page or is there something I can do on an application-wide level which will check the request?
I was thinking of creating a URL rewrite rule which forwards every request to a page which checks the session and either redirect if there is no session or forwards the user to the requested URL if a session exists. Any ideas or thoughts would be appreciated.
Thank you.
You can use IIS rewrite rules for this purpose.
Create a simple rewrite rule like this:
<rule name="Rewrite html">
<match url="/(.*)\.html$" />
<action type="Rewrite" url="{R:1}.asp" />
</rule>
You'll have to consider the directory structure, you are using. Then decide where to put the web.config rules and adjust above rule accordingly.

URL Re-Writing in Umbraco - Page Moved Under New Directory

I'm looking to use the URLRewriting.config within Umbraco to set up some redirects. The majority of them are working fine, but a few are causing headaches.
I have a page: /testpage.aspx which on the new site is now under /directory/testpage.aspx. I've tried a couple of rules, but they either fall into a loop, or just send me to the first page - which obviously gives a 404 error.
As far as I can tell, the rule below should satisfy this rewrite and work, but instead I'm just getting the original page - which is a 404 on this site.
<add name="Redirect400" rewriteUrlParameter="ExcludeFromClientQueryString" redirect="Domain" ignoreCase="true"
virtualUrl="^~/testpage.aspx$"
destinationUrl="/directory/testpage.aspx"
redirectMode="Permanent" />
Those regular expressions (please correct me if I'm wrong), should be saying that any page that starts and ends with /testpage.aspx is redirected to the new URL? Can anyone offer any assistance on this?
there is bit change in your virtual URL because that only gets which has www.domain.com/testpage.aspx
It will not get following results:
www.domain.com/abc/testpage.aspx
www.domain.com/abc/main/testpage.aspx
www.domain.com/abc/main/test/testpage.aspx
Please try following, I haven't tested it but I am guessing it is that.
<add name="Redirect400" rewriteUrlParameter="ExcludeFromClientQueryString" redirect="Domain" ignoreCase="true"
virtualUrl="^~(.*)/testpage.aspx$"
destinationUrl="/directory/testpage.aspx"
redirectMode="Permanent" />
let me know if you need more help
thanks

Resources