简体   繁体   English

我应该在.htaccess中使用哪个IP进行独占访问?

[英]What IP should I use in my .htaccess for exclusive access?

I know there are alot of questions out there related to this, but mine is slightly diferent. 我知道有很多与此相关的问题,但是我的问题略有不同。

I may clear up that I am a junior in PHP (or less) and I am just dealing with new stuff. 我可能会澄清自己是PHP(或更少)的大三学生,并且正在处理新事物。 This is one of those. 这就是其中之一。

Basically I want allow access to my admin folder in my server only to me. 基本上,我只允许我访问服务器中的admin文件夹。 Which, I believe I can achieve through my IP. 我相信我可以通过我的IP实现。 I found this to be put in the .htaccess file: 我发现这是放在.htaccess文件中:

order allow,deny
allow from xxx.xx.xx.xxx
deny from all

Obviously, being the x's my public IP that I got from Google. 显然,x是我从Google获得的公共IP。

Now, when I try to access the folder with my computer it says "403 Forbidden" which means it kind of worked. 现在,当我尝试用计算机访问该文件夹时,它显示“ 403 Forbidden”,这意味着它可以正常工作。 But it is also blocking my IP. 但这也阻碍了我的IP。 So, here comes my questions. 所以,这是我的问题。

Is there more than one IP in a computer? 一台计算机中是否有多个IP? If yes, which one should I use? 如果是,我应该使用哪一个? How can I get it? 我怎么才能得到它? What's the difference among them? 它们之间有什么区别? What am I doing wrong? 我究竟做错了什么?

Any help will be very apreciated. 任何帮助将非常感激。 Thank you in advance. 先感谢您。

EDIT: Also, I am not working on localhost. 编辑:另外,我不在本地主机上工作。 I am working remotely in the server I have uploaded my website to. 我正在将网站上传到的服务器中进行远程工作。

If you going to acces from you own computer, you have to use your local ip, in windows you can find in the console using ipconfig , in unix systems ifconfig . 如果要从自己的计算机访问acces,则必须使用本地ip,在Windows中,您可以在UNIX系统ifconfig使用ipconfig在控制台中找到。

should be something like this 应该是这样的

order allow,deny
allow from 192.168.0.1//127.0.0.1 or localhost
deny from all

Ok, I figured out. 好的,我知道了。 It seems the problem was the order. 看来问题出在订单上。

order deny,allow
deny from all
allow from {mi_ip}

That works, with the other way around deny all seemed to overwrite the allowed IP 可行,以另一种方式deny all似乎覆盖了允许的IP

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM