[英]Allow/Deny Access by IP to a Virtual/PHP Generated URL in .htaccess Without Apache Config Access
我一直在拖拖拉拉,有很多类似的问题/答案,但都不合适,或者我在寻找错误的东西
我使用的是PHP CMS,可路由网址/admin/some-module
/admin
文件夹实际上不存在,因为所有内容都通过index.php
引导程序进行路由。
我正在努力有效地实现
<Directory /admin>
Order Deny,Allow
Deny from all
Allow from <some ip>
</Directory>
但是它是在共享主机上,我们不能更改apache配置来允许它。
如何使用上述设置通过根/public_html/.htaccess
的IP保护URL?
我相信我会在index.php中做到这一点,但在htaccess中,您可以尝试一下
RewriteCond %{REMOTE_ADDR} !^1\.2\.3\.4 [OR]
RewriteCond %{REMOTE_ADDR} !^1\.2\.3\.5
RewriteRule ^admin/ - [L,R=403]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.