Solved

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

Posted on 2008-10-23
1
444 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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
phpmyadmin installation 3 50
PHP temp path missing 4 48
How can I install php on a ngxin server on droplet 5 102
Website being blocked? 3 114
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 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

20 Experts available now in Live!

Get 1:1 Help Now