Solved

Apache Rewrite or Redirect to Send Requests Made to IP to the Hostname

Posted on 2008-10-23
1
445 Views
Last Modified: 2012-05-05
I'm trying to configure apache to where if the client makes a request to my IP address they are redirected to my hostname and away from the IP. This is what I've tried that doesn't work:

  RewriteEngine on
  RewriteRule ^my.ip.here/(.*) http://www.myurl.com/ [L,R=301]

What's the best practice to achieve what I'm trying to do?

Thanks,
Dan
0
Comment
Question by:dancablam
1 Comment
 
LVL 50

Accepted Solution

by:
Steve Bink earned 500 total points
ID: 22786487
What you want is here:

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond

Specifically, the HTTP_HOST variable:

RewriteCond %{HTTP_HOST} !^www.myurl.com$
RewriteRule /?(.+) http://www.myurl.com/$1 [R]
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

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

929 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