Solved

Redirect requests to an IP to the FQDN

Posted on 2012-03-21
4
810 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
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
0
 

Author Comment

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

Accepted Solution

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

Author Closing Comment

by:ausman89
ID: 37961928
no other comments provided a solution
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

867 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

15 Experts available now in Live!

Get 1:1 Help Now