Redirect 301 when accessing my web server via IP address

Greetings everybody!

For some odd reason (it's probably my fault, somehow), Google is indexing pages on my blog via the web server IP address.  This is driving me crazy and I want to stop it.  So, in order to do that, I need to intercept requests for the IP address and do a 301 redirect to the domain name so that Google will stop indexing it.  What would be the easiest way to implement this?

How can I globally intercept each and every request to my web application?  I do not want to have to perform this check on every Page_Load because that's not how I roll.  I'm sure there is a way you can do this at one spot in the code.  Of course I want to get it right the first time so that I don't screw anything else up with Googles indexing.  Any ideas?

By the way: my sitemap is in the correct format, and it correctly points to the domain.

Thanks in advance...


Josh Stodola ← Come check out my blog!
0
JoshStodola
11/13/2007 8:36:17 PM
asp.net.web-forms 93655 articles. 5 followers. Follow

1 Replies
612 Views

Similar Articles

[PageSpeed] 33

Hi,
You need to take a look at HttpModules.. you can create a custom HttpModule that runs for every request.
It provides an event handler to the application object and occurs prior to the Page handler processing.

Take a look at the following link for more info: HttpModules 

Your custom module would more than likely need to hook up the begin request event:
 

public class ExampleModule: IHttpModule
{
	public void Init(HttpApplication application) 
	{ 
		application.BeginRequest += new EventHandler(this.Application_BeginRequest); 
	} 

	private void Application_BeginRequest(object sender, EventArgs e) 
	{ 
		HttpApplication application = (HttpApplication)sender; 
		HttpRequest request = (HttpRequest)application.Context.Request;

		// use the request object to identify url and do something...
		string url = request.Url.ToString();
	}
}
 

Regards,
foreachbiscuit
blog @ http://foreachbiscuit.wordpress.com
0
foreachbiscuit
11/14/2007 5:47:06 PM
Reply:

Similar Artilces:

Access local server(LAN Server) from Web Server(Web Application Server)
Hello All I have a local server for my LAN and a Web server(at remote location).Is it possible to access my Local Server from my Web Server ? Thanks MS  ...

Accessing web service via IP address?
Hi there I am a newbie to web services and am struggling with referencing my web service. What I want to do is access a web service from a Pocket PC 2002 app developed in VS 2003. The web service has been created in another VS 2003 project and would be hosted on a database server to allow for the retrieval and input of information to and from the database. Currently both projects are running on one machine so when I add the reference in the Smart Device App and refer to local host it works perfectly. Obviously, however, once deployed these apps will not be on the same machine and th...

Access Web App from Server IP Address
Hey all, This may actually be more of an IIS quesiton but hopefully someone here knows the answer. I am working with a third party API  and they require my web server ip address and URLs for some HTTP Posting.My Windows 2003 Server web server has multiple websites set up including a default one.If I input the IP into a web browser then it returns my default site.The HTTP Posting will need to use a different App to my default website. How can I reference the required web app when using my Web Server IP Address? kind of like:   http://xxx.xxx.xxx.xxx/webapp/url  ...

web web web
Name: bahadir Email: sensiz_olmuyor_t1_at_hotmail.com Product: Firefox 2 Beta 2 Summary: web web web Comments: web sayfası yapmak Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.8.1b2) Gecko/20060821 Firefox/2.0b2 ...

Accessing two web forms in a single web form
  Hi. I am developing a website in VS 2005 with Ajax & SQL Server. I am having 5 forms in my application. 1) Login Form 2) Main form 3) Form "A" 4) Form "B" I need to show the main form after the User login. I need to show all the contents of form A or form B (Ex: Form "A" user or form "B" user) in the Main Page. Can I show a single page having Main Form controls as well as Form "A" and Form "B" controls? I should access all the controls including Form A/B in the Main Page. Thanks ...

How to access a control on a web form from anoter web form
hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it possible to access lbl1 from form2, change its text permenantly? thanks.   refer: http://dotnetslackers.com/Community/blogs/haissam/archive/2007/11/26/ways-to-pass-data-between-webforms.aspxSSNPlease remember to click "Mark as Answer" on the post that helps you. MinaSamy: hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it p...

Best Practice for .Net Web Service access to a Web Service on a Test and Production Servers
Hello All, What is the best way to control a .Net web service to be able to access a remote server for testing and then point to another remote server to access the web service in production? Do I need to generate and maintain 2 different proxy objects? TIA, Bob Bob // first create the proxy if not isvalid( i_service) then i_service = create fundtraderproxy_TradeServicesClient_BasicHttpBinding_ITradeServices end if ///You'll see code something like this in the constructor of your proxy //dynamically set the endpoint url with the user supplied value - //r...

Accessing Exchange Server address book from .NET web page
Does anyone know how to do this, or if it's even possible with the current version? ...

WEB Access and WEB Server Questions
OK... I really did it now!! I have NW6SP2 and GW6SP2 installed with WEB Access running. I have lost the initial WEB pages that you have on default before I installed WEB Access. SO I now longer have Home, IPrint, IManager, etc. I do not see WEB Access goint to SSL even though I picked that install option. I am using Apache and Tomcat33. I am trying to get this up for demo. I am getting closer. My plans are to have a Hosting page. Then have a link to the services that I want to make available. I know there has to be aa good set of "How To" than documentation whi...

Web form on two web servers
Hi,  Consider a website which is composed of two webforms (for example in two frames) and each one is hosted on a different web server. Is there an easy and secure way to make them share state information with each other? For example, I would like one form to display a picture only if the user can answer a skill testing question in the other form. So form A somehow has to tell form B that it should reload with the picture enabled. I don't want to do it via a cookie on the user's computer, because then the user might be able to fake the cookie and get the picture without answering ...

Web Access on more than one Web Server?
We have built a new server to host our website. Both the old server and the new server are IIS 5 on Windows 2k. We have both the Webaccess agent and the Webaccess application on the web server. Is it possible to install both the WebAccess agent and Webaccess application running on both servers at the same time? It would be nice to be able to test my new server before bringing my old one down. Ed, It appears that in the past few days you have not received a response to your posting. That concerns us, and has triggered this automated reply. Has your problem been r...

add/change name/delete server files via vb.net web form
I have the add(upload) part of this page figured out. I have an application with an "Images" sub directory. I know how to access the getfiles() method from the system.IO namespace. I am using a while loop to create a table with an edit button (so that you can change the name of the file) and a delete button so you can remove the file from the server. Each file is on a new line much like it would look if it was bound to a datalist or datagrid. Here is where I am clueless. Can anyone point me in the right direction? I am not looking for someone to write this for me, beca...

aspx form works in Visual Studio web server but not on my main IIS web server.
Hi all,  I have a simple form that works fine in the VS local web server but when I copy the files (index.aspx, index.aspx.vb, web.config) to my IIS server I can see the form but when I click the hyperlink the form doesn't work. It is as if the .aspx can't execute the .aspx.vb page. Any ideas why this would be?  This is my first asp.net project so I am a complete novice here. Thanks.  My aspx code: <%@ Page Language="VB" AutoEventWireup="false" CodeFile="login.aspx.vb" Inherits="Default2" %> <html xmlns=...

Encrypting web.config with no access to web server
Hello,I've little experience with ASP.NET and I need suggestions to secure data in the web.config file of a web services application.I have to deploy a web services application to a IIS production server located on the customer site. The customer does not allow us any access to this server and it has administrator rights on that machine.What I would like to achieve is to protect connection string configuration in web.config because we don't want that the customer can access the database.What I have read is that I can use RsaProtectedConfigurationProvider at machine level, export a ke...

Web resources about - Redirect 301 when accessing my web server via IP address - asp.net.web-forms

Highest Percentage Of Opera Mini Users Accessing Facebook? Macau
If you were asked to guess which country had the highest percentage of users of Opera mobile Web browser Opera Mini users accessing Facebook ...

International Users Accessing Facebook Places Through US VPN Accounts
By using a virtual private network (VPN) hosted in the United States, Facebook users from around the world are accessing Facebook Places. The ...

What are some alternatives to Yodlee for accessing bank information?
Clay Loveless , Founder, Jexy. Co-founder, Mashery. Founder, Jexy. Co-founder, Mashery.

Cloud Console - Accessing files in cloud storage for iPad on the iTunes App Store
Get Cloud Console - Accessing files in cloud storage on the App Store. See screenshots and ratings, and read customer reviews.

Meryl Streep On Accessing The Characters Within - YouTube
Meryl Streep talks about the importance of an actors work representing their ability. CONNECT WITH AFI: http://facebook.com/AmericanFilmInstitute ...

Student pleads guilty to accessing records about Frances Abbott design scholarship
The Sydney student who leaked information about a fashion school scholarship controversially awarded to the daughter of the Prime Minister has ...

Accessing a headline opinion
Accessing a headline opinion

Sharp increase in authorities accessing private data
Australian law enforcement and government agencies have sharply increased their access without warrant to vast quantities of private telephone ...

Former librarian charged with accessing student records of Frances Abbott
A former part-time librarian at a Sydney design school has been charged after she allegedly accessed student records of Prime Minister Tony Abbott's ...

Frances Abbott scholarship: Sydney woman pleads guilty to accessing Whitehouse Institute records on PM's ...
A Sydney woman who leaked the student records of Tony Abbott's daughter pleads guilty. A Sydney woman who leaked the student records of Prime ...

Resources last updated: 12/17/2015 12:27:06 PM