Coldfusion 9 & IIS7 URL Rewrite - iis-7

I'm currently researching how to implement URL Rewriting and was wondering if someone could help shed some light.
Our current url structure is the following..
http://example.com/products.cfm?id=1234
http://example.com/recipes.cfm?id=6789
I would like to configure IIS so that URLs can be rewritten to the following (or similar)
http://example.com/products/1234/product-title-here
http://example.com/recipes/6789/yummy-recipe-ever
How would I go about doing this?

Read through this walk through. The example comes close to what you want (replaced aspx with cfm).
<rewrite>
<rules>
<rule name="Rewrite to article.aspx">
<match url="^article/([0-9]+)/([_0-9a-z-]+)" />
<action type="Rewrite" url="article.cfm?id={R:1}&title={R:2}" />
</rule>
</rules>
</rewrite>

Look into Coldbox there is a rewrite.ini and IS7 web.config included
http://wiki.coldbox.org/wiki/URLMappings.cfm
The Coldbox blog shared this link
http://blog.coldbox.org/blog/coldbox-and-url-rewrites-with-iis-7

Related

ASP.NET Friendly URLs and default.aspx

I've implemented Friendly URLs in a Webform project but it allows a user to go to either the root of the website or /default. I really want to get rid of the /default option by having it always just route to the root. I've tried using
routes.MapPageRoute("", "Default", "~/")
but that doesn't seem to effect anything.
Anyone now the proper way to accomplish this?
The easiest way to achieve this will be through IIS not in code. It will create a 301 redirect from requests to default.aspx to the root.
<system.webServer>
<rewrite>
<rules>
<rule name="default page" stopProcessing="true">
<match url="^default\.aspx$" />
<action type="Redirect" url="{R:0}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>

Route physical location to rewrited url

I understand how routing works in asp.net web from.
I want to prevent users to access urls like 'Default.aspx'. So when a user tried access url like 'Default.aspx' it redirected to 'Default'.
For example i tried this:
routes.MapPageRoute("", "Default.aspx", "~/Default");
but it does not work! Is there another way?
Please excuse me for poor and bad English.
Webforms or MVC? It's not clear from your question and tagging....
Where have you added this code in your app? It needs to be in application_start() in global.ascx for a WebForms app.
Alternatively, You can try re-writing the url in the web.config (in system.webServer):
<rewrite>
<rules>
<rule name="MyRuleName" stopProcessing="true">
<match url="^default$" ignoreCase="true" />
<action type="Rewrite" url="/default.aspx" />
</rule>
</rules>
</rewrite>

iis7 redirect from exact url to new site

I want to re-direct from an exact URL request to a new site within that domain.
I need to re-direct requests from
www.example.com/site111/default.aspx?configX.xml
(this site uses a different config file to load content)
to
www.example.com/site222/default.aspx
Issue is that I need to leave access www.example.com.au/site111/default.aspx
so I cannot just to a http re-direct as there is no file called default.aspx?configX.xml
I think I need to use a URL rewrite re-direct
Can someone help me with the syntax for the web config I cannot get it to work
0 module installed and have used the above syntax and it still doesn't work,
If I use the test feature on the module it says that the string matches,
very confused,
the actual webconfig section is here
<rewrite>
<rules>
<rule name="Redirect2" stopProcessing="true">
<match url="\/nrmmaps\/default.aspx\?config=nrmproject.xml$" />
<action type="Redirect" url="/nrmproject/default.aspx" redirectType="Permanent"/>
</rule>
</rules>
</rewrite>
and the old link is
http://se.nrmspace.com.au/nrmmaps/default.aspx?config=nrmproject.xml
and I want it to re-direct to
http://se.nrmspace.com.au/nrmproject/default.aspx
Do you have any idea why this is not working?
I believe you need to install the IIS rewrite module which can be found here:
http://www.iis.net/downloads/microsoft/url-rewrite
After you do that, you can add a rewrite section with a redirect rule in your web.config like so:
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect" stopProcessing="true">
<match url="\/site111\/default.aspx\?configX.xml$" />
<action type="Redirect" url="/site222/default.aspx" redirectType="Permanent"/>
</rule>
</rules>
</rewrite>
</system.webServer>
Hope this helps

Need help for regex design in system.webServer rewrite rule in web.config

I am redirecting a lot of old pages because of a new webdesign. However I have run into one little issue.
I want to redirect:
www.domainname.com/Default.aspx
But not redirect
www.domainname.com/somesub/Default.aspx
I need it written like this:
<rule name="301 Redirect Default">
<match url="???????" />
<action type="Redirect" url="http://www.domainname.com/index.php" redirectType="Permanent" />
</rule>
Where the questionmarks mark the regex I need.
Can anyone help?
Cheers
How about
<match url="^Default\.aspx" />
Also see e.g. this article regarding IIS rewrite rules.

IIS7 Rewrite Rule not working

I have created a this rule:
<rewrite>
<rules>
<rule name="ImageRedirect" stopProcessing="false">
<match url="^(.*)/(.*)/" />
<action type="Rewrite" url="http://www.lrgimages.com/ImageRewrite.aspx?=img={R:2}" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
I keep getting a 404.0 message like the rule is not working or IIS is not picking it up. In the test parttern section for the rule, the pattern tests fine. If I go directly to the http://www.lrgimages.com/ImageRewrite.aspx that page loades, but not when I try: http://www.lrgimages.com/TestImage
any thoughts?
Update: I figured it out. It does not take into acount hte http://www.DomainName.com when rewriting a url. Redirects work this way since htat is what is is really doing. I am used to other rewrite engines not taking into account the http://www.DomainName.com . Thanks all you lead me in the right direction.
I don't think "/TestImage" matches ^(.*)/(.*)/ ...

Resources