dtotuki47568 2013-11-10 19:25
浏览 81
已采纳

WordPress是否需要根文件夹中的完整index.php? 有没有更好的方法来防止黑客入侵?

Not a programmer or PHP expert here: please assume entry-level knowledge.

For security reasons, I'd like to allocate the contents of the index.php in my main WordPress folder to something else -- say, fish.php and just have an index.php that calls it, like so:

<html>
<body>

<?php include 'fish.php'; ?>

</body>
</html>

The fish.php file would contain everything that's usually in index.php. It would just be named fish.php.

Will this completely break WordPress? Is a full, detailed index.php file absolutely necessary for it to function, or is it a one-time "load and go" php file that isn't referred to again once WP is in the browser?

  • 写回答

1条回答 默认 最新

  • doujiao9866 2013-11-10 19:35
    关注

    Your question is confusing. So you want another file that then includes the contents of index.php in WordPress? What are you trying to achieve? The basic gist of your question seems to be this line:

    Is a full, detailed index.php file absolutely necessary for it to function, or is it a one-time "load and go" php file that isn't referred to again once WP is in the browser?

    The way content management systems—or virtually any controller based system—works is to flitter all request in one file & then act on them. In WordPress, that is index.php. And it does more than just load the homepage. It’s the gateway page to all other pages. So you can muck around with it, but why? And for what benefit?

    EDIT: The original poster in the comments to my answer explains that they are thinking of ways to prevent a WordPress site from being hacked. Renaming a file will not work. Especially since index.php is only seen on the server side. Let’s say by some crazy config the original poster adjusts Apache to always load fish.php as their index. The web browser—and users & bots—will still get WordPress content. Instead I do the following as a slid brute-force way of avoiding hacks: I place .htaccess password protection on the admin areas of CMS systems. The logic being—and it has worked so far—that most CMS systems are attacked by scripts that hack vulnerabilities in the admin or login process. Yes, some bots might get through. But you can eliminate tons of “low hanging fruit” with this method.

    For example, below is part of the Apache virtual host config that I will use as an example for a site I am calling mygreatsite.com that I have based in the standard /var/www. Note that I am adding authorization for wp-login.php and wp-admin but allowing admin-ajax.php to pass since many functions use it. Now users who administer the site will need to remember an additional—somewhat generic—htpasswd_wordpress_admin user/password combination on top of their standard WordPress credentials. But guess what? Most CMS hacking scripts give up when faced with a browser based password coming from Apache like this.

      # Added for WordPress CMS protection.
      <Directory /var/www/mygreatstite.com/wordpress/wp-login.php>
        Options FollowSymLinks
        AllowOverride all
    
        AuthName "WordPress Login"
        AuthType Basic
        require valid-user
        AuthUserFile /etc/apache2/htpasswd_wordpress_admin
    
        Order Deny,Allow
        Deny from all
        Satisfy Any
      </Directory>
    
      # Added for WordPress CMS protection.
      <Directory /var/www/mygreatstite.com/wordpress/wp-admin>
        Options FollowSymLinks
        AllowOverride all
    
        AuthName "WordPress Admin"
        AuthType Basic
        require valid-user
        AuthUserFile /etc/apache2/htpasswd_cms_admin
    
        Order Deny,Allow
        Deny from all
    
        # Allow 'admin-ajax.php' to pass.
        <Files admin-ajax.php>
          # Order Allow,Deny
          Allow from all
        </Files>
    
        Satisfy Any
    
      </Directory>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系