Bypass htaccess Using Hosts File On Local PC ?

Dushy Squirt

Member
Mar 7, 2013
13
0
1
cPanel Access Level
Website Owner
Hi,

If I have a htaccess file setup using cPanel in the public_html directory of a website to only allow specific IP's through to view the site can this be bypassed by adding a line to the hosts file on anyones local PC.

For example, if I added the line

domain.com 127.0.0.1

to the host file of anyones local PC where that local PC IP address was not in the website htaccess file will that PC be able to view the website?


Thx
 

quietFinn

Well-Known Member
Feb 4, 2006
2,041
551
493
Finland
cPanel Access Level
Root Administrator
That line:
domain.com 127.0.0.1
in the hosts file means that domain.com resides in the same computer where that hosts file is.
127.0.0.1 (i.e. "localhost") always refers to the computer itself.
 

quizknows

Well-Known Member
Oct 20, 2009
1,008
87
78
cPanel Access Level
DataCenter Provider
The hosts file on your local machine is only used to (re)define IP's for domain names. For example if you were migrating a site, you can change your local 'hosts' file to point to the new server instead of where DNS resolves. Assuming you don't use a proxy, your local 'hosts' file will not cause a remote server to see you as coming from a different IP. You can't bypass .htaccess restrictions on a remote sever this way.