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

nginx中如何隐藏php

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

nginx中隐藏php的方法:首先打开相应的配置文件;然后修改内容为“server{listen 80;server_name jiqing.dexin.com;index index.html index.php...”即可。

推荐:《PHP视频教程》

  • 该方法适用于任何品牌的电脑。

nginx 配置隐藏index.php效果

  1. location / {
  2. if (!-e $request_filename) {
  3. rewrite ^(.*)$ /index.php?s=/$1 last;
  4. }
  5. }

完整如下

  1. server
  2. {
  3. listen 80;
  4. #listen [::]:80 default_server ipv6only=on;
  5. server_name jiqing.dexin.com;
  6. index index.html index.htm index.php admin.php;
  7. root /home/wwwroot/default/dexin/dragon/public;
  8. #error_page 404 /404.html;
  9. include enable-php-pathinfo.conf;
  10. location /nginx_status
  11. {
  12. stub_status on;
  13. access_log off;
  14. }
  15. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  16. {
  17. expires 30d;
  18. }
  19. location ~ .*\.(js|css)?$
  20. {
  21. expires 12h;
  22. }
  23. location ~ /\.
  24. {
  25. deny all;
  26. }
  27. location / {
  28. if (!-e $request_filename) {
  29. rewrite ^(.*)$ /index.php?s=/$1 last;
  30. }
  31. }
  32. access_log /home/wwwlogs/access.log;
  33. }

它的功能很简单,如果请求的文件不存在,自动加上index.php。

这样,它既支持index.php/Home/index。也支持/Home/index。

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

人气教程排行