I want to rewrite URLs from my website:
Existing URL:
http://mywebsite/_layouts/namespace/core/page.aspx
I want to get this URL:
http://mywebsite/core/page.aspx
I added this code to the web.config file on the <system.webServer> section but nothing has been changed :(
<rewrite>
<rules>
<rule name="Core Pages" enabled="true" stopProcessing="true">
<match url="^core/([.]+)" />
<action type="Rewrite" url="_layouts/namespace/core/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
Can you help me please ?
Try this for your match url:
<match url="^core/(.+)" />
Related
I trying to build a rewrite rule to "Permanent Redirect" of a PHP page to MVC site. here is the URL of PHP site
/Home/new-age-xxx.php & url of MVC site to which I want user to redirect "/home/new-age-xxx"
here is my URL rewriting rule
<rule name="Imported Rule 1-599" stopProcessing="true">
<match url="^home\new/-age/-xxx\.php$" ignoreCase="false" />
<action type="Redirect" url="/home/new-age-xxx" appendQueryString="false" redirectType="Permanent" />
</rule>
It is not redirecting to /home/new-age-xxx, even i tried to move it to other urls like /login/index
Any suggestion?
Thanks
You could use a bewlo url rewrite rule to redirect one site url to another site:
e.g:
Request URL: http://www.sample2.com/home/new-age-123.php
Redirect url:http://www.example.com/home/new-age-123
<rule name="reg redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{REQUEST_URI}" pattern="/home/new\-age\-([0-9]{1,3}).php$" />
</conditions>
<action type="Redirect" url="http://www.example.com/home/new-age-{C:1}" appendQueryString="false" />
</rule>
To learn more about url rewrite module you could refer the bewlo link:
Creating Rewrite Rules for the URL Rewrite Module
Regards,
Jalpa
I had to change previous URL pattern to something else. Earlier URL pattern was
www.testdomain.com/hotels/"city" and it changed to www.testdomain.com/hotel-"city"
Below is the redirection I have used that for.
<rule name="cityChange" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^hotels/(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="www.testdomain.com" />
</conditions>
<action type="Redirect" url="www.testdomain.com/hotel-{R:1}"appendQueryString="false" redirectType="Temporary" />
</rule>
Now I have another issue which is another URL I have used for the site is also redirecting to different one. That URL is,
www.testdomain.com/hotels/'city'/'name'-'street'-'postalcode'
Since I have used a wildcard for /hotels/'city' to /hotel-'city' it changes above URL as
www.testdomain.com/hotel-'city'/'name'-'street'-'postalcode'
as well. But that URL is not valid in the site and I do not want to replace "/" from "-" there.
How can I exclude this URL pattern from that wild card which I have mentioned above?
Thanks in advance.
Can't be sure about that but did you try to add parentheses, like that ?
<match url="^(hotels)/(.*)" />
We did that for ou specific wildcard redirect :
<rule name="modeles-en" enabled="true" stopProcessing="true">
<match url="^(modeles-en)/(.*)" ignoreCase="true" />
<action type="Redirect" url="/models/{R:2}" redirectType="Permanent" />
</rule>
Hope it helps !
I am working on vb.net application and i need to remove word "sections" from the url.
url: http://www.examplewebsite.com/sections/page.aspx
This is what i need to do by regular expression in web.config.
You can use the following rewrite rule in your web.config file:
<rewrite>
<rules>
<rule name="Hide sections">
<match url="^(.+)$
<action type="Rewrite" url="sections/{R:1}" />
</rule>
</rules>
</rewrite>
I need to create a URL rewrite rule in IIS for the following:
From:
http://hostname/virtual_path_folder/myisapi.dll?a=1&b=1
To:
http://hostname/myisapi.dll?a=1&b=1
Basically, I'd just like to hide the virtual_path folder if possible.
You could go with the 2 following rules:
<rules>
<rule name="Redirect if virtual_path_folder" stopProcessing="true">
<match url="^virtual_path_folder/(.*)$" />
<action type="Redirect" url="{R:1}" />
</rule>
<rule name="Rewrite to sub folder">
<match url="^.*$" />
<action type="Rewrite" url="virtual_path_folder/{R:0}" />
</rule>
</rules>
The first one, Redirect if virtual_path_folder, will redirect every request starting with virtual_path_folder/. It will prevent anyone from accessing your content using the sub folder.
The second one rewrites any request (^.*$) to the sub folder: virtual_path_folder/{R:0}
This is what I'm trying to achieve using web.config (My current web.config is used to force non-www which will still be needed)
The site was first hosted under a sub-folder and we moved it now to the root. This is what I'm trying to achieve now:
old url example: mysite.com/subfolder/prodView.asp?idproduct=1312&idCategory=44 should get redirected to mysite.com/prodView.asp?idproduct=1312&idCategory=44 (We need to get rid of the old subfolder)
This is will be needed as many customer have already saved products link in their browsers and also we posted 1000's on links on twitter and facebook that all include the sub-folder within.
Any help will be highly appreciated.
Current web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Remove WWW prefix" stopProcessing="false">
<match url="(.*)" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.mysite\.com$" />
</conditions>
<action type="Redirect" url="http://mysite.com/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Add the following rule to your existing rule(s):
<rule name="Redirect old subfolder links" stopProcessing="false">
<match url="^subfolder/(.+)" ignoreCase="true" />
<action type="Redirect" url="/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>