Redirecting a domain using IIS - 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

Related

DNS redirect of a url to another url

We are currently looking at identifying the best approach to carry out a redirection of a url folder to another url folder o a separate domain. We have tried a few options but have been unable to make this work. Any other redirection options such as apache, html etc are not possible. This url is only accessed through the browser by an application to download some files. This application cannot be changed but needs to download these files from another location.
Hence, we need to redirect the following:
https://sub1.domain1.com/xyz
to
https://sub2.domain2.com/abc/xyz
Any ideas how we can achieve this?
Note: we have full control of DNS of the domain1 and there are no plans to use this domain.
You can't do that with DNS alone. The DNS never sees the "path" part of the URL. You need a webserver aware of the situation who can provide a 302 redirect.

domain name with or without 'www'

I have a domain e.g. named www.example.com, when people type in example.com, it still can be accessed, but won't automatically add that 'www' to the url.
But as for website like facebook, if you type in facebook.com, it'll automatically add that 'www', BEFORE loading the page for you.
Probably I didn't explain it well, but guess you see the difference and get my point anyway.
So how can I make my domain acts like facebook, when people type example.com, it'll automatically add that www for them?
EDIT:
Ok, so I need a redirect to the 'www' subdomain. Actually I'm using nodejs, which hosted on Amazon EC2, to serve the webpage instead of Apache HTTP. So any equivalent of .htaccess in nodejs area?
I guess now the question shifts to more nodejs oriented, and it turns out it becomes a redundant of this thread:
Redirect all requests using Express 3?
Thanks all for your help.
you have to set your domain 301 permanent redirect in your control panel.
if your website is hosted in CPANEL then
GOTO -> Redirects in ( Domains Menu )
Choose the type Permanent (301)
choose your domain.com
www.domain.com in redirects to→ __
check the box on Redirect with or without www
finally CLick ADD
if your website is hosted in PLESK then
do it in your program level
or
plesk11.0.29 version above supports the 301 peramanent
You can do all of this with a .htaccess file.
https://kb.mediatemple.net/questions/242/How+do+I+redirect+my+site+using+a+.htaccess+file%3F
# This allows you to redirect your entire website to any other domain
Redirect 301 / http://mt-example.com/
Add this in a file named .htaccess on your host, but set it to the URL you want your main page to be.
To make a .htaccess file, you can always go in FTP, upload an empty .txt file, open it with notepad, put in the lines of code above, then rename it to .htaccess.

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

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

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.

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]

Resources