私はWebサーバー上の.phpファイルへの直接アクセスを制限しようとしています。allow localhost;すべてを否定する。 "index.php"と "/"にかかわらずすべてのために
使用allow localhost;deny all;
。ただし、これによってもindex.php
へのアクセスが制限されます。
この問題を解決するにはどうすればよいですか? IF conditions
のようなものはありますか?
マイ設定:一般的に行われているもの
if ($request_uri ~* "^(/)index\.php$") {
return 301 $1;
}
location/{
try_files $uri $uri/ /index.php?$args;
rewrite ^/(\w+)$ /?system=$1 break;
rewrite ^/(\w+)/(\w+)(/.)*$ /?system=$1&id=$2 break;
rewrite ^/(.*)/$ /$1 permanent;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param PHP_VALUE "auto_prepend_file=/usr/share/nginx/html/web/config.php";
}
}
あなたは 'localhost'を許可言うとき - あなたはURLのホストの面で何を意味するのですか? 'http:// localhost/something'ですか? – wick
つまり、サーバー自体(POSTなど)で行われたクエリ以外のすべてのクエリを拒否します。 – Leeloo
POSTここで、「http:// localhost/my.php」または「http://my.domain」。 com/my.php'? – wick