当前位置:Gxlcms > PHP教程 > nginx如何隐藏.php

nginx如何隐藏.php

时间:2021-07-01 10:21:17 帮助过:34人阅读

nginx隐藏.php的方法:首先打开“nginx.conf”文件;然后添加代码为“try_files $uri $uri/ $uri.php?$args;”;最后完成nginx.conf修改即可。

推荐:《PHP视频教程》

在/usr/local/nginx/conf 下打开nginx.conf,在service{}添加一段代码,

  1. location / {
  2. try_files $uri $uri/ $uri.php?$args;
  3. }

完成nginx.conf如下:

  1. user www www;
  2. worker_processes auto;
  3. error_log /home/wwwlogs/nginx_error.log crit;
  4. pid /usr/local/nginx/logs/nginx.pid;
  5. #Specifies the value for maximum file descriptors that can be opened by this process.
  6. worker_rlimit_nofile 51200;
  7. events
  8. {
  9. use epoll;
  10. worker_connections 51200;
  11. multi_accept on;
  12. }
  13. http
  14. {
  15. include mime.types;
  16. default_type application/octet-stream;
  17. server_names_hash_bucket_size 128;
  18. client_header_buffer_size 32k;
  19. large_client_header_buffers 4 32k;
  20. client_max_body_size 50m;
  21. sendfile on;
  22. tcp_nopush on;
  23. keepalive_timeout 60;
  24. tcp_nodelay on;
  25. fastcgi_connect_timeout 300;
  26. fastcgi_send_timeout 300;
  27. fastcgi_read_timeout 300;
  28. fastcgi_buffer_size 64k;
  29. fastcgi_buffers 4 64k;
  30. fastcgi_busy_buffers_size 128k;
  31. fastcgi_temp_file_write_size 256k;
  32. gzip on;
  33. gzip_min_length 1k;
  34. gzip_buffers 4 16k;
  35. gzip_http_version 1.1;
  36. gzip_comp_level 2;
  37. gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
  38. gzip_vary on;
  39. gzip_proxied expired no-cache no-store private auth;
  40. gzip_disable "MSIE [1-6]\\.";
  41. #limit_conn_zone $binary_remote_addr zone=perip:10m;
  42. ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.
  43. server_tokens off;
  44. access_log off;
  45. server
  46. {
  47. listen 10000 default_server;
  48. #listen [::]:80 default_server ipv6only=on;
  49. server_name _;
  50. index index.html index.htm index.php;
  51. root /home/wwwroot/default/src;
  52. #error_page 404 /404.html;
  53. # Deny access to PHP files in specific directory
  54. #location ~ /(wp-content|uploads|wp-includes|images)/.*\\.php$ { deny all; }
  55. include enable-php.conf;
  56. location /nginx_status
  57. {
  58. stub_status on;
  59. access_log off;
  60. }
  61. location ~ .*\\.(gif|jpg|jpeg|png|bmp|swf)$
  62. {
  63. expires 30d;
  64. }
  65. location ~ .*\\.(js|css)?$
  66. {
  67. expires 12h;
  68. }
  69. location ~ /.well-known {
  70. allow all;
  71. }
  72. location ~ /\\.
  73. {
  74. deny all;
  75. }
  76. location / {
  77. try_files $uri $uri/ $uri.php?$args;
  78. }
  79. access_log /home/wwwlogs/access.log;
  80. }
  81. include vhost/*.conf;
  82. }

以上就是nginx如何隐藏.php的详细内容,更多请关注gxlcms其它相关文章!

人气教程排行