Is it possible to rewrite subfolder to subdomain with IIS7? - asp.net

I have an asp.net application on sub domain sub.domain.com I want to access this application by typing www.domain.com/sub is it possible with IIS7?

Assuming you're happy to manually configure the application at each subdomain:
In IIS Manager, go to Sites, and select your www.domain.com site.
Right click it, "Add Application" and specify the alias "sub" and point the physical path to the same location as sub.domain.com
Select the same application pool as the sub.domain.com site.
Alternatively you could set up a redirect by creating a new Virtual Directory in your www.domain.com site, then dropping in a default.html file that does a http redirect.
A posher (and more transparent to the user) redirect could be done like so:
Open an elevated command prompt
run the following command:
%windir%\system32\inetsrv\appcmd set config "nameofsite/virtualdirectoryname" -section:system.webServer/httpRedirect -enabled:true -destination:destinationofredirect -commitpath:apphost
I lifted that from: http://www.andrewwestgarth.co.uk/Blog/post/2008/07/31/Creating-Http-Redirects-in-IIS7-on-Virtual-Directories-like-IIS6.aspx

Related

can't get my web site, on IIS, to work with URL beginning with www

I added my vb.net web app to IIS 8 on my Azure Windows 2012 server R2 VM.
Then, I did IIS > right-click Sites > Add Web Site
and set "Site name" to my_site.org
and set Physical path to project directory for my web site
and set "Host name" also to my_site.org.
Works great. From Internet, I browse to http://my_site.org and it runs OK.
Now I want people to also browse to www.my_site.org
but when I Add Web Site, just like above, but for www.my_site.org
it adds ok, but when I select www.my_site.org and click IIS Browse www.my_site.org browser pops up but reads "webpage cannot be found"
Nor can I browse it from Internet.
Because what is WWW? essentially that is a subdomain that you would need WWW to exist for it to load WWW.
Best option may be to set up domain forwarding to WWW, maybe a CNAME in your domain options?
From Azure documentation, "You must also provide the domain or subdomain alias for the CNAME, such as www if you want to create an alias for www.customdomain.com. If you want to create an alias for the root domain, it may be listed as the '#' symbol in your registrar's DNS tools."
More at:
https://azure.microsoft.com/en-us/documentation/articles/cloud-services-custom-domain-name/
Hope this helps! :)
Shahed

IIS redirection to external web site

Is it possible to create local web site in local IIS with some domain, for example. dummy-website
and when locally enter that domain to be redirected to some other web site in internet, note that after redirection url need to stay dummy-website, content of web site from internet needs to be displayed in requested local domain.
Tnx
yes there is:
In IIS Manager, expand the local computer, right-click the Web site or directory you want to redirect, and click Properties.
Click the Home Directory, Virtual Directory, or Directory tab.
Under The content for this source should come from, click A redirection to a URL.
In the Redirect to box, type the URL of the destination directory or Web site. For example, to redirect all requests for files in the Catalog directory to the NewCatalog directory, type /NewCatalog.
and there you go!
Hope this helps.

How to redirect a binding in IIS 7.5 (Windows 2008 R2)?

I have a "Default Web Site" with different apps under it... I have setup a HOST (A) record for a DNS name "support.mydomain.com" which points to the IIS server.
In the IIS bindings, i have configured the new HOST (A) record binding, what I would like to do is redirect any requests going to support.mydomain.com to a folder under my "Default Web Site" wwwroot.
As shown in the pictures, I'd like to redirect anything going to support.mydomain.com to the Default Web Site > App > SI folder.
Right now, it shows the standard IIS7 "welcome" page which is at the root (Default Web Site).
Any ideas?
Thank you.
You will need to use IIS URL Rewrite module for this.
http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module

point ip to a virtual path

I have a webserver asp.net with 1 ip and several domain name.
let say:
174.1.1.1
with domain.com domain2.com domain3.com
If i go to 174.1.1.1 it show
"Under Construction
The site you are trying to view does not currently have a default page. It may be in the process of being upgraded and configured."
So If I navigate to 174.1.1.1 I want it redirect to domain2.com
so how can I do that?
I'm using visual studio 2010 with win xp and iis
IIS6: To redirect requests to another Web site or directory
In IIS Manager, expand the local computer, right-click the Web site or directory you want to redirect, and click Properties.
Click the Home Directory, Virtual Directory, or Directory tab.
Under The content for this source should come from, click A redirection to a URL.
In the Redirect to box, type the URL of the destination directory or Web site. For example, to redirect all requests for files
in the Catalog directory to the NewCatalog directory, type
/NewCatalog.
IIS7: Configure the Web Server to Redirect Requests to an Exact Destination
Open IIS Manager and navigate to the level you want to manage. For information about opening IIS Manager, see Open IIS Manager (IIS 7).
For information about navigating to locations in the UI based on your
IIS administrative role, see Navigation in IIS Manager (IIS 7).
In Features View, double-click HTTP Redirect.
On the HTTP Redirect page, under Redirect Behavior, select Redirect all requests to exact destination (instead of relative to
destination).
In the Actions pane, click Apply.

IIS Default Redirect

In IIS7, if the default redirect at the website level is a relative path, how to make the default redirect is on https and not http.
Currently if the host is: abc.com and the login page is abc.com/myapp/login.aspx, I set the default redirect (IIS manager -> HTTPRedirect) to /myapp/login.aspx. So, if the user enters abc.com in his browser address bar, he gets redirected to http://abc.com/myapp/login.aspx. I want to make sure the user gets redirected to http*s*://abc.com/myapp/login.aspx.
Would it need a web.config at the root level?
Note that this cannot be done in asp.net code, because the asp.net code is not involved in the processing of this request
Edit:
One way to do it is having a "default" web app i.e. web app deployed at the root (web site) level and then use the standard redirection module available with asp.net. Any thoughts on pros, cons?
Finally we came up with 3 different options:
Use an index.htm at the "Web Site" level and put a javascript that would set the
window.location.href to the https URL.
Use the IIS URL rewrite module
Use a custom asp.net module to do the redirection to a https URL. The dll for this module will be registered in GAC and the module configured at the "Web Site" level. The registration in GAC is necessary because the module will be invoked for the child applications of the "Web Site"
The option 3 was selected based on :
Ease of Deployment. Installing the rewrite module on all the front end servers is more complex than installing a dll in GAC
Support for non-browser User Agents that will not parse the javascript. This eliminates option 1.

Resources