PDA

View Full Version : best approach to "hide" my ip number from web browsers



PhonemeAnalysis
04-09-2010, 09:17 AM
hello all -

i have a lot of domains running on my westhost server.

the problem is (was) that if somebody did a whois, they could get my IP number, and then pull up my primary website. i didnt want this to happen.

in other words, i didnt want anybody to be able to look at one of my non-primary websites and then go to my primary website (sorry, but i am a little bit ashamed of it :-)

so i put this into my .htaccess file:
RewriteEngine on
RewriteCond %{HTTP_HOST} !edwardsmark.com
RewriteRule .* - [F,L]

translation, if somebody accesses my server and does not use my primary website but rather my ip number, stop 'em. now they would get the message "forbidden" if they use my ip number.

i thought it might have been a nice option to pull up another webpage instead of the nasty looking "forbidden" message, but RewriteRule kept throwing me into a loop and i gave up looking for a solution.

any better ideas?

thanks!

bruce.binder
04-09-2010, 06:04 PM
I think what you want is a "canonical hostname". I'm unashamedly copying this from the apache site, but I have not tested it.

See http://httpd.apache.org/docs/2.0/rewrite/rewrite_guide.html

Canonical Hostnames

Description:

The goal of this rule is to force the use of a particular hostname, in preference to other hostnames which may be used to reach the same site. For example, if you wish to force the use of www.example.com instead of example.com, you might use a variant of the following recipe.

Solution:

[...]

RewriteCond %{HTTP_HOST} !^fully\.qualified\.domain\.name [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://fully.qualified.domain.name/$1 [L,R]

wildjokerdesign
04-16-2010, 03:15 PM
The only thing that I would add to that is that your RewriteRule should not be what Bruce posted. You don't really want them to see your site so you could actually make is something like this:


RewriteRule ^/(.*) http://fully.qualified.domain.name/noaccess.html [L,R]

The only problem is that they are still going to see the domain name this way and then all they need to do is backspace and they see your site. What might even be better is to redirect them to one of your domains that you are not ashamed of. ;)

Actually you now have my curiosity peeked and I want to see your main domain. It can't be that bad. :)