简体   繁体   English

通过IP允许/拒绝访问.htaccess中虚拟/ PHP生成的URL,而无需Apache Config访问

[英]Allow/Deny Access by IP to a Virtual/PHP Generated URL in .htaccess Without Apache Config Access

I've been trawling around, and theres many similar questions/answers, but none that fit, Or I'm searching for the wrong things 我一直在拖拖拉拉,有很多类似的问题/答案,但都不合适,或者我在寻找错误的东西

I'm using a PHP CMS, that routes the urls /admin/some-module 我使用的是PHP CMS,可路由网址/admin/some-module

The /admin folder doesnt actually exist, as everything routes through an index.php bootloader. /admin文件夹实际上不存在,因为所有内容都通过index.php引导程序进行路由。

I'm trying to effectively achieve 我正在努力有效地实现

<Directory /admin>
    Order Deny,Allow
    Deny from all
    Allow from <some ip>
</Directory>

However it is on shared hosting which we cannot change the apache config to allow this. 但是它是在共享主机上,我们不能更改apache配置来允许它。

How can you protect a url by IP from the root /public_html/.htaccess with the above setup? 如何使用上述设置通过根/public_html/.htaccess的IP保护URL?

I believe I'd do that in the index.php but in htaccess you could try this 我相信我会在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.

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