URL rewriting - Rule seems ok but completely ignored IIS 7 - url-rewriting

I want to redirect request going to "oldSubDomain" to "newSubDomain".
Here what the URL looks like :
https://oldSubDomain.myWebSite.com
should go to
https//newSubDomain.myWebSite.com
Here the rule as it has been added to the web.config :
<system.webServer>
<rewrite>
<rules>
<rule name="NewSubDomain">
<match url=".*oldSubDomain.*" />
<action type="Redirect" url="https://newSubDomain.myWebSite.com/" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
Rule seems OK, but when I go to "https://oldSubDomain.myWebSite.com", the rule seems being ignored and I get the oldsubdomain pages...
I am using IIS7.0 and the web application is done using MVC 4.5.
An idea ? Anyone ?
Many thanks.

See this answer. Basically it appears that the only portion you will be given is the portion relative to your web.config file. It is possible that if you have the web.config defined in the mywebsite.com directory that you are only getting the myWebSite.com portion for matching.

Related

I need IIS Manager rewrite rule to view a page when you are at a different url

On a windows server. I want a user to see the page www.example.org/placrun when they go to www.example.org/placestorun, but I want the url to be www.example.org/placestorun. Essential I need the url changed. Any help on this would be great
The name of this feature is "Rewrite". You need to add this rewrite rule to your web.config file:
<rule name="Rewrite placestorun">
<match url="^placestorun$"/>
<action type="Rewrite" url="/placrun"/>
</rule>
The regexp ^placestorun$ will match only if you visit URL www.example.org/placestorun and <action type="Rewrite" url="/placrun"/> define a result that you want to rewrite it to placrun URL

Url Rewrite not working in umbraco 7

I added the below code to redirect in urlrewrite.config
<add name="regx" virtualUrl="~/about/(.*)/2016/(.*)/12/"
redirect="Application" destinationUrl="~/about/$1"
redirectMode="Permanent" />
And i added the below code to rewrite in web.config
<rewrite>
<rules>
<rule name="regx">
<match url="^/about/news/2016/(.*)/12/" />
<action type="Rewrite" url="about/news/2016/{R:1}/12" />
</rule>
</rules>
</rewrite>
This above code change my url from "//192.168.18.159:8741/about/news/2016/feb/12" to "//192.168.18.159:8741/about/news/". It get redirect to news page i am not able to get redirect to exact url as "//192.168.18.159:8741/about/news/2016/feb/12"
i am not able to get rewrite and redirect i added the UrlRewritingNet.UrlRewriter.dll and used correctly in web config.
i need to change my url from "//192.168.18.159:8741/about/news/2016/feb/12" to "//192.168.18.159:8741/about/news/feb/"
Please give some solution as soon as possible. Thanks in advance

IIS Url rewrites with Sitecore

I'm using the IIS URL rewrite add-on in my Sitecore v7.2 website to handle redirects.
I've setup the Rewrites on the website node in IIS and not on the top level IIS server.
These are simple redirects such as appending a slash in certain situations
<rule name="CA Redirect" stopProcessing="true">
<match url="^ca$" />
<action type="Rewrite" url="{R:0}/" />
</rule>
I'm finding that unless I add the path e.g. "/ca" to the IgnoreUrlPrefixes in Sitecore IIS will not process the redirect, and it appears that Sitecore is handling the request before the URL rewrite rule.
Has anyone else come across this issue? Should the rules be added at the top level rather than the website level?
We're using redirects at website level and it works without problems. IIS is redirecting before Sitecore handles the request.
Doing it at site level is generating this in the web.config
<rewrite>
<rules>
<rule name="Web closed" enabled="true" stopProcessing="true" patternSyntax="Wildcard">
<match url="*" />
<action type="Rewrite" url="/holdingpage.html" logRewrittenUrl="true" redirectType="Temporary" />
</rule>
</rules>
</rewrite>

How to configure web.config to load resources form external server

I'm developing a web application in Visual Studio 2013 and am getting my data from an external server. For this reason I disable the web securtiy in my browser and define absolute URLs in my application. Now whenever I'm deploying the applicaiton, I have to adopt the URLs (which of course get's forgotten the first time) and also I have to explain the setup to evey person new in the porject.
After getting a bit fimilar with the web.config file, I tried to setup some rules, to rewirte this urls to the data webserver, but failed.
All my relative urls start with the same identifyer, and should be mapped to an external server. This is what I have so far:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite calls to rest.oms to the actuall webserver">
<match url="^/IDENTFIER/([_0-9a-z-]+)" />
<action type="Rewrite" url="http://EXTERNAL_SERVER/IDENTFIER/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
However, it is not working so far. Can somebody help me please.
Best Regards,
Stefan
It is possible to rewrite from external url, if you have ARR module.
1) You need to install ARR module for your IIS
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) Slightly fix your rewrite rule regexp (remove starting slash):
<rule name="Rewrite calls to rest.oms to the actuall webserver">
<match url="^IDENTFIER/([_0-9a-z-]+)" />
<action type="Rewrite" url="http://EXTERNAL_SERVER/IDENTFIER/{R:1}" />
</rule>
Then your rule should work.

"Rewrite Action" 404 Server Error! (IIS 7.0 MS URL Re-Write Module)!

Can anyone tell me why this is returning a 404 but works when I redirect it!
<rule name="Static All Paging" stopProcessing="true">
<match url="(.*)page-([0-9]+)$" />
<action type="Rewrite" url="{R:1}?P={R:2}" appendQueryString="true" />
</rule>
The easiest thing to do is enable Failed Request Tracing and see the end-result of the URL Rewriting http://learn.iis.net/page.aspx/467/using-failed-request-tracing-to-trace-rewrite-rules/
There are a couple of things that could be happening but is hard to know. Are you sure both URLs are running in the Same Application Pool? That could be one reason why redirect works but not rewrite.

Resources