I try to redirect www.myDNNSite.com/hastinfo/[...] to http://172.16.244.43:83/[...] in DNN 7.x
To do that, I added a rule in SiteUrls.config as this blog showed https://bertcraven.wordpress.com/2008/05/21/quick-n-dirty-redirects-in-dotnetnuke/
<RewriterRule>
<LookFor>[^?]*/hastinfo/(.*)</LookFor>
<SendTo>http://172.16.244.43:83/$1</SendTo>
</RewriterRule>
This not work if there is a . after hastinfo, so:
www.myDNNSite.com/hastinfo/test -> OK 172.16.244.43:83/test
www.myDNNSite.com/hastinfo/myhandler.axd -> KO error 404 and no redirection
It seems that DNN make something with URL if there is a . founded.
How to make my redirection working even if a . (dot) is present in url ?
EDIT:
My objective with this redirection is to have the same end point for my dev and production environment. I have three server on the front end and the Web Service behind the www.myDNNSite.com/hastinfo point to three differents servers to load balance the charge.
Before update to DNN 7.X, I was using ManagedFusionRewriter that make the job.
But It is not updated from 2009 and now with IIS 8.5 I look a better way to make this redirection from a config file.
EDIT 2:
I try to add IIS Mod Rewrite in my IIS 8.5 and write in Web.config:
<rewrite>
<rules>
<rule name="Imported Rule 101" stopProcessing="true">
<match url="^hastinfo/(.*)" />
<action type="Rewrite" url="http://172.16.244.43:83/{R:1}" appendQueryString="true" />
</rule>
Without success ... here the Failed Tracing:
Using IIS Redirects in combination with the DNN Friendly Url providers is often a recipe for disaster sadly.
In this case, the reason that you are having issues more than likely is that the .axd is being captured by the ASP.NET process and that is preventing the re-writing from happening.
Based on what you are looking to do, can you explain a bit the true goal? The reason for this answer rather than a "do this" is that redirecting with DNN to a non-standard port is also going to cause issues as there is a setting for "usePortNumber" in the web.config that you will want to have on if using a non-standard port.
I finally found a way to make it works.
Thanks to: http://blogs.msdn.com/b/asiatech/archive/2011/08/25/return-404-4-not-found-when-url-rewrite.aspx
You need to install Application Request Routing and enable Proxy, then it will work with URL rewriting to remote servers (regardless where or what they are) since the Routing will take care of that.
http://www.iis.net/download/ApplicationRequestRouting
Related
I'm working on rerouting a particular route to a different Application in the same IIS site but it sits in a different app pool. Although I have gotten this to rewrite the URL it doesn't allow it rewrite to a app that is in a different app pool without using ARR(Application Request Routing) or so I've read.
I'm currently trying to just do a redirect and seems to be directing fine for GET request but when I make POST calls too it it fails with "Method not allowed". Using fiddler it is doing a GET when I send down a POST.
If anyone can make some suggestions if it is possible for this to just redirect the URL but keep the same request body and method?
My "rewrite" is as follows with some minor details changed
<rewrite>
<rules>
<rule name="REST1 to REST2" stopProcessing="true">
<match url="^REST1/Service/([_0-9a-z-]+)" />
<action type="Redirect" url="site.com/REST2/Service/{R:1}" />
</rule>
</rules>
</rewrite>
This seems to redirect the URL just fine but not the method or request body.
Is this something I'm going to have to do with a rewrite? If so any suggestion for doing this when sending the request to a app in a different app pool.
Your rule will respond with a 301 status code redirection which the client (I assume browser) then decides what to do with. If your client is not a browser, you could maybe tell it to replay the same request to the new endpoint. Otherwise Rewrite (or Rewrite + ARR if you want cross AppPools) is how you'd do this.
Please try changing the action type to Rewrite instead of Redirect.
A redirect always results redirect header being sent to the browser. This changes the URL in the browser address bar, and the browser then issues an HTTP GET for the new address. With an HTTP GET, no form/post data are ever sent; all arguments are assumed to be in the URL querystring.
If you'd like to avoid the redirect and use a true rewrite, change your web.config to use action=rewrite. Using this method, no redirect header is sent back to the browser, the browser address bar never changes, and IIS simply redirects the current request stream to a different location.
I have searched around for the answer to this but cant find anything that fits my exact scenario.
Currently have the below set up :
RootApplication(sitea.bla) .NET 3.5
- ChildApplication (sitea.bla/service1) .NET 3.5
The root application is being rewritten in .NET 4.5 but the service1 application will not be being updated in this current phase and will be removed as an child application.
I have moved the service1 application to a sub domain (service1.sitea.bla)so it can run in an legacy application pool.
This works perfectly though I have multiple other applications/services/clients that reference the original endpoint. I have set up a IIS redirect which works perfectly in the browser
sitea.bla/service1/exampleservice.asmx gets redirected to service1.sitea.bla/exampleservice.asmx
Though when making a call through a client application it fails unless I manually change the endpoint to the new sub domain . I have also tried achieving through a reverse proxy.
What is the best method to achieve this without manually changing all the endpoints to the new sub domain?
You need to setup correct rewrite rule:
1) You need to install ARR module (you need it, because you rewriting requests to different application)
2) In IIS manager you should enable reverse proxy
2.1) On server node click "Application Request Routing Cache"
2.2) Click "Server proxy settings" and click "Enable proxy", then "Apply"
3) In web.config of application sitea.bla add this rewrite rule:
<rule name="rewrite service1" stopProcessing="true">
<match url="^service1(.*)" />
<action type="Rewrite" url="http://service1.sitea.bla{R:1}" />
</rule>
4) Try to make a call to sitea.bla/service1/exampleservice.asmx
I'm new to URL Rewrite.
I created a WCF Rest service, and I'm trying to set a rewrite rule that will allow invoking the service when the svc extension is hidden.
I have a method named "Test" on that service, that I invoke successfully with the svc extension present.
What I did:
Created a rule in the web config:
Checked the Rule shows in IIS under ReWrite features.
Validated it works as I expect by clicking the "test pattern" button and entering the URL details:
Did IISReset (Several times).
I'm getting a 404 when trying this URL:
http://localhost/WcfTestApp/Service1/Test
Additional Stuff:
I also enabled "Failed Request Tracing Rules" But I see no logs created in the folder.
Any Ideas why it isn't working as I expect?
Thanks in advance for any help.
What I did to resolve it:
I fixed the failed request tracing log files not appearing, turns out you need to configure in the IIS settings the status codes for which the trace should occur, as it's not smart enough to select all by default.
Then via the trace file (which I opened in IE), I noticed my rewrite rule needed a slight modification, as I was able to see what URL I got, and what it was rewritten to (which did not work).
Eventually, that's what I used.
<rule name="RemoveSvcExtension" stopProcessing="true">
<match url="^(.*)Service1/(.*)$" />
<action type="Rewrite" url="{R:1}Service1.svc/{R:2}" logRewrittenUrl="true" />
</rule>
I've got a custom HttpModule to redirect legacy URLs from an old build of the site which checks the incoming request URL against a database table of redirects.
However, when the incoming request URL contains a plus (+) sign, the request doesn't fall through the HttpModule - it works as expected for standard URLs.
For example, these URLs works:
http://www.example.com/sample-url
http://www.example.com/sample url
http://www.example.com/sample%20url
These don't:
http://www.example.com/sample+url
http://www.example.com/sample%2Burl
Here's my module declaration:
<add name="LegacyUrlHttpModule" type="Web.LegacyUrlHttpModule, Framework.Web" preCondition="managedHandler" />
Am I missing a setting here or something?
Scott Hanselmann wrote a nice blog post explaining how you could enable all kind of crap symbols in the Path portion of an url.
His conclusion is the following:
After ALL this effort to get crazy stuff in the Request Path, it's
worth mentioning that simply keeping the values as a part of the Query
String (remember WAY back at the beginning of this post?) is easier,
cleaner, more flexible, and more secure.
So basically if you have such characters in a url, those characters should be passed as query string parameters instead of attempting to pass them in the Path portion.
IIS rejects + in URLs by default. A workaround would be to allowDoubleEscaping
<system.webServer>
<security>
<requestFiltering allowDoubleEscaping="true" />
</security>
</system.webServer>
but beware that this may make your site more vulnerable to malicious URLs.
You can follow the below steps:
in the IIS webserver section, double click the 'Request Filtering' icon
in the 'File Name Extension' right click->Edit Feature Settings...' the file 'web.config'
check the option 'Allow double escaping' (this option is unchecked by default)
repeat all above 3 steps for the 'default website' (or whatever you have given the name to your site)
re-start the IIS
Has anybody tried using Intelligencia.UrlRewriter for http to https and vice versa redirection of page. i cant seem to make it work on my site. Although I was able to use the rewrite between http pages.
Thanks a lot in advance.
This seems to work for me, in web.config:
<rewriter>
<if header="HTTPS" match="^OFF$">
<redirect url="(.*)" to="https://mydomain$1" />
</if>
</rewriter>
Although I found with IIS and MVC, at least, that setting [RequireHttps] will handle the http -> https redirection automatically with a 302.