I am using ASP.NET URL Rewrite module and wrote this rule :
<rewrite>
<rules>
<rule name="test">
<match url="http://localhost/ElWazefa/User/Ahmed/ahmed.aspx"/>
<action type="Rewrite" url="http://localhost/ElWazefa/ahmed.aspx"/>
</rule>
</rules>
</rewrite>
But it doesn't work.
using asp.net 3.5 and XML IntelliSense for URL Rewrite 2.0
Thanks in advance.
the code syntax seems to be correct
try to check your URLs for typos or leave the port/host out of the URL like that:
"/ElWazefa/User/Ahmed/ahmed.aspx"
I think your URLs can't include the protocol/host/port portion. Try:
<rewrite>
<rules>
<rule name="test">
<match url="/ElWazefa/User/Ahmed/ahmed.aspx"/>
<action type="Rewrite" url="/ElWazefa/ahmed.aspx"/>
</rule>
</rules>
</rewrite>
Related
Need some help specifying rewrite rule for:
http://example.com/page/my-unique-title
to
http://example.com/page?id=my-unique-title
Note it is web forms app and I am using friendlyurls. Any help much appreciated.
Try this:
<rule name="myrule" stopProcessing="true">
<match url="page/(.*)" />
<action type="Rewrite" url="page?id={R:1}" />
</rule>
I have a subdomain, test1.test.com, i want to do a url rewriting on that subdomain to rewrite all requests to point other domain. For example i want to rewrite all request to test1.test.com to point http://www.AAA.com
here is my rewrite rule.
<rewrite>
<rules>
<rule name="Rewrite sample">
<match url="(.*)" />
<action type="Rewrite" url="http://www.AAA.com" />
</rule>
</rules>
</rewrite>
the result is not what i expected.
"The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."
It's not possible to rewrite to another domain. Rewrite deals only with the last part of the url (after the domain) so the only way to change domain is to use redirect like this:
<rewrite>
<rules>
<rule name="Test" stopProcessing="true">
<match url="test1.test.com" />
<action type="Redirect" url="http://www.AAA.com"/>
</rule>
</rules>
</rewrite>
I have a site that currently uses the .aspx extension on its pages. It's getting a Joomla conversion and the .aspx extension will not work anymore. I need it so that if someone enters the .aspx extension, it will just get removed the URL so none of the SEO on the current site breaks.
For example, I need
www.arrc.com.php5-17.websitetestlink.com/services/managed-services.aspx
to be rewritten/redirected to
www.arrc.com.php5-17.websitetestlink.com/services/managed-services
This is what I have in my web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Migrate to PHP">
<match url="^([_0-9a-z-]+)\.aspx" />
<action type="Redirect" redirectType="Permanent" url="{R:1}" />
</rule>
<rule name="Rewrite .aspx">
<match url="^([_0-9a-z-]+)/?([_0-9a-z-]+)\.aspx" />
<action type="Redirect" redirectType="Permanent" url="{R:1}/{R:2}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
The first URL match is for any URLs that have a URL like services.aspx instead of services/managed-services.aspx
Whenever I go to www.arrc.com.php5-17.websitetestlink.com/services/managed-services.aspx it gives me an internal server error, but www.arrc.com.php5-17.websitetestlink.com/services.aspx rewrites correctly. What can I do to fix this?
They are greedy, switch the order.
<rule name="Rewrite .aspx">
<match url="^([_0-9a-z-]+)/?([_0-9a-z-]+)\.aspx" />
<action type="Redirect" redirectType="Permanent" url="{R:1}/{R:2}" />
</rule>
<rule name="Migrate to PHP">
<match url="^([_0-9a-z-]+)\.aspx" />
<action type="Redirect" redirectType="Permanent" url="{R:1}" />
</rule>
Two potential issues:
I think for rewriting, it's going to hit them in order, which means the first rule is going to always kick off. Try switching the order of the rule.
The dash should work correctly in [_0-9a-z-], but try escaping the dash.
When request comes to www.example.com/default.aspx, I want it to 301 to www.example.com. How to do that?
PS - I tried many rules but nothing seems to work. Thanks.
Have you tried using URL Rewrite with the following rule:
<rule name="Default Document" stopProcessing="true">
<match url="(.*)default.aspx" />
<action type="Redirect" url="{R:1}" redirectType="Permanent" />
</rule>
Here is my settings for IIS 7 URL Rewrite:
<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite to article.aspx">
<match url="^Articles/([0-9]+)/([_0-9a-z-]+)" />
<action type="Rewrite" url="articledetails.aspx?articleid={R:1}&title={R:2}" />
</rule>
</rules>
</rewrite>
</system.webServer>
Unfortunately, my page at the following url is not displayed at all:
http://www.highoncoding.com/Articles/723_Introduction_to_IPhone_Development.aspx
Looks like you are giving in the wrong URL.
<match url="^Articles/([0-9]+)/([_0-9a-z-]+)" />
The above rule will match /Articles/723/Introduction_to_Iphone_Development. You are giving it /Articles/723_Introduction_to_Iphone_Development (underscore instead of slash). Seems that you fixed it as I am typing this though :)