Solved

Redirect requests to an IP to the FQDN

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

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

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?
0
Comment
Question by:ausman89
  • 3
4 Comments
 
LVL 16

Expert Comment

by:Easwaran Paramasivam
Comment Utility
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
0
 

Author Comment

by:ausman89
Comment Utility
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.
0
 

Accepted Solution

by:
ausman89 earned 0 total points
Comment Utility
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.
0
 

Author Closing Comment

by:ausman89
Comment Utility
no other comments provided a solution
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

What is an ISAPI filter?   •      It's an assembly (.dll file) that can add or change the way IIS works.   •      They can be enabled globally for your web server or on a site-by-site basis.   When the IIS server receives a request, enabling the ISAPI fi…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now