Open a web application when request is made to IIS server root - iis

Using IIS7, I have a web application (lets say it is called "MyWebApp" installed under "Default Web Site", on my web server (lets say it is called www.mywebserver.com)
What I want to achieve is that when a browser makes a request to www.mywebserver.com, I want to open MyWebApp, as if the request was www.mywebserver.com/MyWebApp.
How do I achieve this?

Do a redirect, there are several ways to do that:
Add an html page with a meta refresh
Use ASP .NET Redirection methods (Response.Redirect and Server.Transfer)
Use IIS Redirect
I'd recommend the IIS Redirect. Follow these steps:
Open IIS Manager and navigate to the level you want to manage.
In Features View, double-click HTTP Redirect.
On the HTTP Redirect page, select Redirect requests to this destination. In the corresponding box, type the file name, directory path, or URL to which you want to redirect the user.
In the Actions pane, click Apply.

Related

Using custom error pages with ARR / Application Request Routing

How can I display custom HTML instead of the following 502 response from ARR?
Traffic is directed to the server farm using a URL Rewrite rule on the server level.
Open IIS and then on the server level, in the IIS section, click "Error codes". These files are global, which is the level you will want to change for your situation. There are also site level error pages. You can modify these files or you can point them to a different file that you have customizedIIS Error Pages.

Redirect or rewrite from www.somedomain.com to www.somedomain.com/en/ in IIS

This is what I would like to achieve:
A user surfs to www.somedomain.com
IIS rewrites the url/redirects to www.somedomain.com/en/
How to create such a rule in IIS?
Open IIS Manager and navigate to the level you want to manage.
In Features View, double-click HTTP Redirect.
On the HTTP Redirect page, select Redirect requests to this destination.
In the corresponding box, type the file name, directory path, or URL to which you want to redirect the user.
In the Actions pane, click Apply.
http://technet.microsoft.com/en-us/library/cc732930(v=ws.10).aspx

Redirecting a domain using IIS

I am currently having two domains www.xyz.com and www.pqr.com. If anybody enters xyz.com I need to bringout the website pqr.com
Both are on the same server.
Kindly suggest how to go about this.
Thanks
In internet services manager, right
click on the file or folder you wish
to redirect then select "Properties"
Select the radio titled "a redirection to a URL".
Enter the redirection page
Check "The exact url entered above" and the "A permanent redirection for this resource"
Click on 'Apply'
From http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/6b855a7a-0884-4508-ba95-079f38c77017.mspx?mfr=true
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.
If you want to say that "you should always go to foo instead of bar," you want a 301 redirect (which you do with your front-end server). See http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=93633
A 302 (temporary) redirect should be used in cases where you can't serve a page, but expect it to come back later. Unfortunately, it's the redirect that you get from JSP forward.
A client-side (meta refresh or javascript) redirect should be avoided whenever possible.
Apache docs for configuring a permanent (or temporary) redirect.
If you want pqr.com to appear in the user's browser's address bar, you'll have to send a 301/302 redirect response, either through a script or through your web server's configuration - how to do this depends on what software you are using.
If you are using IIS7 and you have installed URL Rewrite Module then use this article for more information : IIS URL Rewrite – Redirect multiple domain names to one

How to redirect a URL path in IIS?

In IIS 6.0, is there an easy way to re-direct requests to a folder to another folder, while preserving the rest of the path.
e.g.
If I have moved the content from:
mysite.org.uk/stuff
to
stuff.mysite.org.uk/
Can I automatically redirect requests for specific pages like
mysite.org.uk/stuff/countrybriefing/tanzania/travel.html
to
stuff.mysite.org.uk/countrybriefing/tanzania/travel.html
I know that .htaccess can do things like this in Apache, is there an equivalent in IIS?
Format the redirect URL in the following way:
stuff.mysite.org.uk$S$Q
The $S will say that any path must be applied to the new URL.
$Q says that any parameter variables must be passed to the new URL.
In IIS 7.0, you must enable the option Redirect to exact destination.
I believe there must be an option like this in IIS 6.0 too.
Taken from Microsoft Technet.
Redirecting Web Sites in IIS 6.0 (IIS 6.0)
When a browser requests a page or program on your Web site, the Web server locates the page identified by the URL and returns it to the browser. When you move a page on your Web site, you can't always correct all of the links that refer to the old URL of the page. To make sure that browsers can find the page at the new URL, you can instruct the Web server to redirect the browser to the new URL.
You can redirect requests for files in one directory to a different directory, to a different Web site, or to another file in a different directory. When the browser requests the file at the original URL, the Web server instructs the browser to request the page by using the new URL.
Important
You must be a member of the Administrators group on the local computer to perform the following procedure or procedures. As a security best practice, log on to your computer by using an account that is not in the Administrators group, and then use the runas command to run IIS Manager as an administrator. At a command prompt, type runas /user:Administrative_AccountName "mmc %systemroot%\system32\inetsrv\iis.msc".
Procedures
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.
To redirect all requests to a single file
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 file.
Select the The exact URL entered above check box to prevent the Web server from appending the original file name to the destination URL.
You can use wildcards and redirect variables in the destination URL to precisely control how the original URL is translated into the destination URL.
You can also use the redirect method to redirect all requests for files in a particular directory to a program. Generally, you should pass any parameters from the original URL to the program, which you can do by using redirect variables.
To redirect requests to a program
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 program, including any redirect variables needed to pass parameters to the program. For example, to redirect all requests for scripts in a Scripts directory to a logging program that records the requested URL and any parameters passed with the URL, type /Scripts/Logger.exe?URL=$V+PARAMS=$P. $V and $P are redirect variables.
Select the The exact URL entered above check box to prevent the Web server from appending the original file name to the destination URL.
If you have loads of re-directs to create, having loads of virtual directories over the places is a nightmare to maintain. You could try using ISAPI redirect an IIS extension. Then all you re-directs are managed in one place.
http://www.isapirewrite.com/docs/
It allows also you to match patterns based on reg ex expressions etc. I've used where I've had to re-direct 100's of pages and its saved a lot of time.
Here's the config for ISAPI_Rewrite 3:
RewriteBase /
RewriteCond %{HTTP_HOST} ^mysite.org.uk$ [NC]
RewriteRule ^stuff/(.+)$ http://stuff.mysite.org.uk/$1 [NC,R=301,L]

IIS7 startup site

I have a Windows 2008 Server with IIS7 on it and a web page running under the name, let's say myApplication. I have a domain name that points to the IP of my server, let's say myApplication.com.
In order to access my application I have to enter http://myApplication.com/myApplication.
If I write http://myApplication.com/ I arrive to the IIS7 start page. Is there a way (besides rewriting the iisstart.htm to make a JavaScript or meta-data redirect) to automatically open the myApplication when someone enters "http://myApplication.com/"?
What I would like is the following:
The user enters in the browser: "http://myApplication.com/"
He/she is taken to "http://myApplication.com/myApplication"
In the URL bar of the browser only "http://myApplication.com/" shows and everything inside the application is relative to this URL.
Generally when I configure IIS, I set the properties for the "default web site" to a folder that doesn't contain anything, then create individual entries within IIS for each web site. For example, you would create a new entry for "MyApplication.com" and set its home directory to the proper folder on the server that contains your root files (usually c:\inetpub\wwwroot\myapplication.com\ but it could be anywhere you like).
It sounds as if you have created a folder for your application, but do not have a specific entry in IIS configured to handle the requests and load files from the proper folder.
If you have a dedicated IP address for the application, be sure to specify that IP within the site settings for that site. If you're using a single IP for multiple sites, configure the IP AND hostnames/domains that will be used to access that site so IIS will know which site entries belong to which domains and where to route the requests.

Resources