.htaccess deny from x.x.x.x 不适用于重写规则 .* 索引.php [L].



我正在尝试通过 .htaccess 文件限制我的 ip,它在没有RewriteRule .* index.php [L]的情况下工作正常 我在这里很困惑,浪费了一整天来解决这个问题,即使在文件乞求和所有其他 htaccess 语句的末尾,我也尝试了 deny 语句。 我在下面提到了我的代码,请帮助我解决这个问题。

DirectoryIndex index.php
<IfModule mod_php5.c>
    php_value memory_limit 256M
    php_value max_execution_time 18000
    php_flag magic_quotes_gpc off
    php_flag session.auto_start off
    php_flag suhosin.session.cryptua off
    php_flag zend.ze1_compatibility_mode Off
</IfModule>
<IfModule mod_security.c>
    SecFilterEngine Off
    SecFilterScanPOST Off
</IfModule>
<IfModule mod_deflate.c>
</IfModule>
<IfModule mod_ssl.c>
    SSLOptions StdEnvVars
</IfModule>

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule ^api/rest api.php?type=rest [QSA,L]
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
    RewriteRule .* - [L,R=405]
    <IfModule mod_setenvif.c>
        <IfModule mod_headers.c>
            Header set X-Content-Type-Options: nosniff
            BrowserMatch bMSIEs8 ie8
            Header set X-XSS-Protection: "1; mode=block" env=!ie8
        </IfModule>
    </IfModule>
    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule .* index.php [L] # When i comment this line the below code works fine but with this line i am unable to limit the site.
</IfModule>
Order deny,allow
Allow from all
Deny from 110.93.244.176

经过大量的研究和伪代码,我终于发现了问题所在,问题是Apache版本,我想我只是更改了代码

Order deny,allow
Allow from all
Deny from 110.93.244.176

<RequireAll>
    Require all granted 
    Require not ip 110.93.244.176
</RequireAll>

希望这对其他人有用。

mé 的上下文不清楚。无论如何,请删除行Allow from all,然后重试。

最新更新