Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Redirect requests to an IP to the FQDN

Posted on 2012-03-21
4
Medium Priority
?
844 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

636 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