Solved

Redirect requests to an IP to the FQDN

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

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…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

830 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