Solved

Redirect requests to an IP to the FQDN

Posted on 2012-03-21
4
829 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

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…
Lync server 2013 or Skype for business Backup Service Error ID 4049 – After File Share Migration
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

691 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