Solved

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

Posted on 2008-10-23
1
448 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Redirect URL's containing question marks 5 74
RewrteRule using htacess 10 76
PHP Register global 21 96
Apache LDAP Authentication 20 31
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

861 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