Url Rewrite not working in umbraco 7 - url-rewriting

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

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

How to write IIS rewrite rule to redirect request to different server?

I have my main website running at a hosting company with IIS 7.5 at http://example.com
I'm setting up a WordPress blog at the same hosting company on a Linux, Apache, PHP machine.
When a user types in "http://example.com/blog" I want to redirect the request to the WordPress site.
To the end user they wouldn't know the blog content is being served up from a different server.
What is the specific IIS rewrite rule needed to do this?
<rewrite>
<rules>
<rule name="Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.mysite1.com$" />
</conditions>
<action type="Redirect" url="www.mysite2.com" />
</rule>
</rules>
</rewrite>

URL rewriting - Rule seems ok but completely ignored IIS 7

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.

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>

IIS URL rewriting to redirect querystring addresses to MVC style path to preserve old links

I am trying to preserve old links such as index.php?pageid=123 to the now current /accounts/home. No part of the original URL has to be included in the redirect.
I have a big list of old page links and their new address. I thought it would be really simple to say index.php?pageid=123 = /accounts/home but I can't see how to do it. Most of the examples I see are the other way around whereby your site uses query string and you want your URLs to be SEO friendly. I'm using IIS 7.5 to rewrite.
Thanks
Got it sorted and it wasn't that hard really. Just needed to add the query string as a condition.
<rules>
<rule name="accounting" patternSyntax="Wildcard" stopProcessing="true">
<match url="index1.php" />
<conditions>
<add input="{QUERY_STRING}" pattern="page=accounts/accountsmain" />
</conditions>
<action type="Redirect" url="business-services/accounting.aspx" appendQueryString="false" />
</rule>
</rules>

Resources