Redirect requests to an IP to the FQDN

Posted on 2012-03-21
Medium Priority
Last Modified: 2012-05-13
I am trying to redirect all requests from let's say* to http://www.example.com/*

I tried using the following code in my web.config file, but keep getting a "500 Internal Error":
				<rule name="IP Redirect" stopProcessing="true">
					<match url="(.*)" />
							<add input="{HTTP_HOST}" pattern="11\.12\.13\.14" />
						<action type="Redirect" url="http://www.example.com/{R:1}" />

Open in new window

So, if I cannot get it to redirect through the web.config file, I thought it may be possible to do it through the .vb script pages, since there is only a couple pages due to security reasons that I need the redirect working for.

SO...Does anyone have an idea on how to better handle this so that when my website gets requested by an IP address that it automatically redirects to the domain name?
Question by:ausman89
  • 3
LVL 16

Expert Comment

by:Easwaran Paramasivam
ID: 37748241
In your example the IP is different from the code that you have given.

Please do use Regex for validating IP Address http://www.tipsntracks.com/112/regular-expressions-ip-address-validation-with-net.html

Author Comment

ID: 37748269
The IP address is an example, and is not real... For reasons of anonymity, I do not want to state my actual domain or ip address.  But, sorry I got mixed up and did not use the same fake IP throughout the whole question.

Accepted Solution

ausman89 earned 0 total points
ID: 37942880
This was completed using a combination of a couple of vb.net statements using elements like "HttpContext.Current.Request.Url.AbsoluteUri" with a couple if-then statements and a resulting "Response.Redirect" condition.

Author Closing Comment

ID: 37961928
no other comments provided a solution

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Running classic asp applications under Windows Server 2008 R2 (x64) and IIS 7 is not as easy as one may think. It took me a while to figure it out while getting error 8002801d a few times. After you install the OS you will need to install the fol…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
If you are looking for an automated solution for backup single or multiple Office 365 user mailboxes to Outlook data file, then you can use Kernel Office 365 Backup & Restore tool. Go through the video to check out the steps to backup single or mult…
From store locators to asset tracking and route optimization, learn how leading companies are using Google Maps APIs throughout the customer journey to increase checkout conversions, boost user engagement, and optimize order fulfillment. Powered …

619 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question