I have a domain pointer called like pointer.com which is pointing at my site which is like www.mysite.com. My application start folder for pointer.com is a folder named pointer. I might have a second pointer called pointer2.com and it would be in a folder named pointer2. My main site, www.mysite.com is at the root of my site. So I want to be able to enter either of the following in my browser: pointer.com www.pointer.com And I need it to go to http://pointer.com/pointer Actually I have a default.aspx in both pointed folders, so what I really need the browser to do is to go to http://pointer.com/pointer/default.aspx Now I can do this with a simple program in my root that looks like this: protected void Page_Load(object sender, EventArgs e) { EnableViewState = false; string site = Request.ServerVariables["HTTP_HOST"]; Response.Write(string.Format("Site is {0}", site)); if ((site == "pointer.com") || (site == "www.pointer.com")) { Response.Write("Using old way to redirect."); Response.Redirect("http://pointer.com/pointer/default.aspx"); } } However, the browser then shows ther url as "http://pointer.com/pointer/default.aspx" instead of "http://pointer.com/default.aspx" which is what I'd like to see. I've tried using the URL Rewrite through the IIS Manager but it just doesn't seem to work. I figure I'm not setting up the rules correctly. Here are two rules I tried <rewrite> <rules> <rule name="pointer rule" enabled="true"> <match url="pointer.com" /> <action type= "Rewrite" url="http://{R:0}/pointer/default.aspx" /> </rule> <rule name="pointer2 rule"> <match url="pointer2.com" /> <action type= "Rewrite" url="{R:0}/pointer2/default.aspx" /> </rule> </rules> </rewrite> Any Ideas anyone?
I figured it out... In case anyone is interested I think I figured it out. If I add this rule then I can do exactly what I want. <rewrite> <rules> <rule name="pointer test" stopProcessing="false"> <match url=".*" /> <conditions> <add input="{HTTP_HOST}" pattern="pointer.com" /> </conditions> <action type="Rewrite" url="pointer/default.aspx" /> </rule> </rules> </rewrite> So, I couldn't get any help on this but maybe someone else can benefit from my research!
Well, this works but not quite as I would have hoped. The pointerDomain site doesn't seem to be able to access any relative paths that are in the script. I guess it is using the re-written URL. More investigation needed now. I'll take help if it is out there!
I suspect that it has to do with the fact that you are Rewriting all requests to pointer/default.aspx. Try pointer/{R:1} instead.
url rewrite fixed Thanks. That was almost was perfect. I just had to change it to pointer/{R:0} instead of pointer/{R:1}
Here's a rewriting rule that can go it web.config in the root, and direct both x.y and www.x.y to a subfolder sitedir.x.y, regardless of what x and y are. It assumes you have no urls that begin with sitedir. The advantage is that you don't have to change web.config every time you add a new site, if you simply follow the sitedir.x.y convention. <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <clear /> <rule name="^sitedir." stopProcessing="true"> <match url="^sitedir." /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false" /> <action type="None" /> </rule> <rule name="Remove www" patternSyntax="ECMAScript" stopProcessing="true"> <match url="(.*)" negate="false" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> <add input="{HTTP_HOST}" pattern="(^www\.)(.+)" /> </conditions> <action type="Rewrite" url="sitedir.{C:2}/{PATH_INFO}" appendQueryString="true" /> </rule> <rule name="WildCard" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false" /> <action type="Rewrite" url="sitedir.{HTTP_HOST}/{PATH_INFO}" /> </rule> </rules> </rewrite> <directoryBrowse enabled="false" /> </system.webServer> </configuration>
WOW, actually this is a nice rule. I'm gonna have to test this out. Of course this may hinder some people who have domain pointers and they have those additional domain names point to a different sub folder.
Handling URLs with Hyphens Note that the web.config I posted on 5/25/10 does not work on domain names that contain hyphens. I forget why, but I think it's because filenames cannot contain hyphens. Attached is a new version. It's untested in this form, but it probably works.
I mostly use Silverlight for new development, but I do have one AJAX page that seems to work OK. It uses a Microsoft UpdatePanel and a Telerik RadComboBox. Do you know why your AJAX breaks?
Well no not really it never made any sense, i keep getting errors like: ASP.NET Ajax client-side framework failed to load and 'Sys' is undefined. What seems to be breaking it is that ScriptResource.axd is not actually being generated and i can't figure out why. Have you ever had this problem? If not could you please send me an example of a working Microsoft ASP.NET AJAX Application that works with URL Rewriting or something .
This doesn't sound like a URL problem. Really, the best thing to do is send a full and complete copy of the error message and if possible send us a URL and a way to see the error on our end. One of the most common problems with diagnosing coding problems is the person seeing the problem concludes to what he/she thinks is the problem and leads everybody to that path, when in essence it is completely something else. So its always best to just give the exact error first then let someone else (a new fresh set of eyes) conclude what the problem maybe.
http://www.gabrielsadaka.com.au/ajax/default.aspx After heaps of work i mangaged to get it working with internet explorer but for some reason neither firefox nor chrome can render the ajax properly :S Just to let you know I'm only 16 so I don't really have a great deal of experience in this .
WOW you guys are getting younger and younger everyday. The fact that you are already dealing with AJAX/.Net/WCF will definitely put you on the path in the world of programming. Keep it up, before you know it a lot of corporations will be knocking at your door to hire you. As for firefox and chrome, AJAX relies on or should I say requires client side java scripting. You may want to make sure you got the latest version of java installed on your computer.
Actually for some reason it doesn't work in Internet Explorer either, i think that would be because i got rid of the URL rewrite rule to test it, which made it work, then set it back but i didn't clear the temporary files, so it just loaded up the original one which worked without the URL rewriting. So in conclusion it actually doesn't work in any browser like it was in the beginning, any other ideas (installing java won't fix it because JavaScript and Java are entirely unrelated )
The browser errors you are getting it not very helpful. Go to this site and download fiddler and install it on your computer. It is a debugger application and it will log all the http calls your AJAX application will make. This should give you a more better understanding on what is going on in the back end and implement a solution to it. http://www.fiddler2.com/fiddler2/
been there done that sorry i should've mentiod that fiddler showed that ScriptResource.axd is giving a 404 error, from that i have guessed that for some reason it is either not getting generated at all or it is being generated in a different location, either way isn't very helpful :S
I found the solution to this. I'm at work and I can't use FTP to get the rules. I got ajax working in sub folders. I will post a separate write up because lots of people need it.
Ran into this thread a while ago while looking for a similar solution myself, didn't give the the result I needed so I went googling . I think this is probably one of the best solutions for use of urlrewrite with multiple (sub)domains on a site, so figured I'd share it: http://weblogs.asp.net/owscott/arch...-hosting-multiple-domains-under-one-site.aspx
pleunv, Scott has been working with me to come up with the rules I have posted in the programming forum. I"m not sure if he updated his blog yet, but I followed his blog 100% correctly and it wasn't working. That's when he got involved and got us a working solution He'll be working with me again on some SEO friendly rewrites and I'll be sure to post anything he offers up. It seems even the basic things aren't always so basic.