x.x.x.x的.htaccess拒绝与RewriteRule。* index.php不兼容[L]

时间:2019-01-29 12:43:49

标签: php apache .htaccess

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

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 \bMSIE\s8 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

2 个答案:

答案 0 :(得分:1)

经过大量研究和伪代码,我终于找到了问题,问题是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>

希望这对其他人有用。

答案 1 :(得分:0)

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