I have some rewrite rules that were working with a IIS rewrite tool for IIS 6, but now I have ported them to IIS 7 rewrite. Here is the rule:
Pattern:
/resource/(.*)/.*
Action URL:
/index.cfm?go=resources&details=1&rid={R:1}
Before it was rewriting it correctly now it is hijacking all of the images for example:
/resources/assets/images/gopic.jpg
What am I doing wrong?
Thanks,
Josh
Instead of this, you may use IIS 7 Rewrite Module.
You may find some useful information about it from the below article :
http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module
Also, I have just blogged about it with an example implementation. It might help as well :
http://www.tugberkugurlu.com/archive/remove-trailing-slash-from-the-urls-of-your-asp-net-web-site-with-iis-7-url-rewrite-module
Related
In IIS 8.5 - Need to URL (framnaes) - https://www.manpowergroup.no/framnaes to new
web site - https://framnes-installasjon.no.
I have tried many pattern and condition. But not working.Could you please help me to fix it.
Sorry! In my previous POst/Answere I am not able to post whole Rule tag.
Anyways here this regular expression "/[^/]+/sub-dir-name" worked for me to find out the specific directory in url and then redirect to another website.
Thanks
I have one issue with my site. I need to hide Default.aspx from Url. My web site project uses urlrewriter net and I tried using it to make this but no success.
I read lot of articles on net how to do this but nothings work.
Does this is only possible to set on IIS ?
I wont all ways to have www.test.com instead of www.test.com/default.aspx
Please for best solution ?
If you're using iis 7 or above, this might be a way of going about it.
The Microsoft URL Rewrite Module 2.0 for IIS 7 and above enables IIS administrators to create powerful customized rules to map request URLs to friendly URLs that are easier for users to remember and easier for search engines to find. You can use the URL Rewrite module to perform URL manipulation tasks.
http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module
And heres a link to see the module in action.
http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module
After reading tons of articles this is solution for my problem..
setting this javascript onto masterpage
var testremove = location.href.toLowerCase().indexOf("default.aspx");
if (testremove != -1) {location.replace(location.href.substring(0,testremove))};
I've done some url rewriting, always using the Intelligencia.UrlRewriter and it always worked fine. But now i want to achieve the following and somehow i can't get it right.
i want:
www.mydomain.com/products/books > rewrite to www.mydomain.com/products.aspx?id=books
this works fine, because i can set my criteria to /products/..
www.mydomain.com/mybook > rewrite to www.mydomain.com/productdetails.aspx?id=mybook
and of course i want www.mydomain.com/newbooks.aspx to function normally
and these last 2 don't work together.
is there a way i can tell my rewrite rule to only rewrite when there is no extension in my url? or is there an other trick?
Thanks in advance!
Well, a bit off the road, but try using ASP.NET Routing instead of URL Rewriter.
I was playing (and messing up) with the rewriter, and here on Stackoverflow I was advised to use Routing, and it is MUCH better (and easier when you get it).
You'll need some little changes to your ASPX files though, but very small.
I thought i'd solve this old, unanswered question. The problem with the extensionless urls turned out to be some configuration problem in IIS. Our system admin fixed this by allowing these urls and after that the rewriter had no problems picking up and translating the URLS.
I know this question is overly popular, but I find nothing that addresses rewriting the host, only rewriting the path.
How could I accomplish redirecting/rewriting "http://myHost.com" to "http://myAlias.com/hidden/default.html"?
ADDED: where myAlias is just an alias of myHost.
Quick and dirty ... Create a default document for the site (default.aspx for example) to redirect to /hidden/default.html
Along the lines of what James had mentioned with the default.aspx in your root. Then you could rewrite simply..
HttpContext.Current.RewritePath("http://myHost.com/hidden/default.html");
You can use an ISAPI-filter in IIS, like Helicon to rewrite the document path:
http://www.isapirewrite.com/
The lite version is free
Edit:
Ok, your want to redirect to another domain. I don't think that Helicon supports that.
You can try (c#):
HttpContext.Current.Response.Redirect("http://myAlias.com/hidden/default.html");
We are thinking of renaming our web directory schema to be more user friendly. However, we need any URL requests for the old directory structure to forward to the new one. so....
How do I forward requests for all of these:
http://mydomain.com/OLDdirname/
http://mydomain.com/OLDdirname/samesubdir/
http://mydomain.com/OLDdirname/samesubdir/samescript.aspx
to each of these respectively:
http://mydomain.com/NEWdirname/
http://mydomain.com/NEWdirname/samesubdir/
http://mydomain.com/NEWdirname/samesubdir/samescript.aspx
Any suggestions and perhaps some general guidance as far as gotchas?
You can use a number of things to do something like this. Basically, you're doing URL Rewriting. One of these products should help you get the job done:
ISAPI Rewrite
IIS Rewrite
opURL
IIRF
I use IIRF on many of my websites, and it has always worked without failing. You use regular expressions to define the rules, and it takes care of the rest. It would be extremely easy to setup a few redirects using IIRF.
http://cheeso.members.winisp.net/IIRF.aspx