Nginx how to return 404 when access index.php directly -
for security purpose, attempting hide fingerprint info of web application. of import thing hide php
visitors. seek modify nginx
's configuration file. configuration show follows.
location / { root /data/site/public; index index.html index.htm index.php; try_files $uri /index.php; location /index.php { fastcgi_pass unix:/var/run/php5-fpm.sock; include fastcgi.conf; } }
by way, hide index.php
url. however, hackers straight access website using url such http://example.com/index.php
, shows website written php
. maybe dangerous. so, modify nginx
's config sec time, longing 404
when access index.php
directly, , looks like
location / { root /data/site/public; if ( $request_uri ~ /index\.php ) { homecoming 404; } index index.html index.htm index.php; try_files $uri /index.php; location /index.php { fastcgi_pass unix:/var/run/php5-fpm.sock; include fastcgi.conf; } }
however..., seems nginx
acts nil different previous one.
could tell me reason ? or other solutions...
php nginx
No comments:
Post a Comment