哪些WordPress脚本需要可执行才能进行全新安装?

时间:2014-07-04 作者:Philipp

出于安全原因,我需要阻止对新WordPress安装中不会执行的脚本的访问。

示例:

索引。php-->需要可执行,包括/缓存。php-->不应执行(它包含在其他文件中)任何人都知道哪些文件是included 而这实际上需要executable?

我想建立一个可以通过执行的有效文件列表。htaccess,如下所示:

<小时>

Update:

这是。htaccess文件我有-我的实际问题是:这个配置完成了吗,或者我需要允许更多的文件才能让新的WordPress安装正常工作?

<IfModule mod_rewrite.c>
  # ONLY ALLOW THESE SCRIPTS TO EXECUTE:

  # == Login, Signup, Activate
  RewriteRule ^wp-login.php - [L]
  RewriteRule ^wp-activate.php - [L]
  RewriteRule ^wp-signup.php - [L]
  # == All admin scripts and WYSIWYG editor
  RewriteRule ^wp-admin/ - [L]
  RewriteRule ^wp-includes/js/tinymce/wp-tinymce.php - [L]
  # == WP Cron and mail
  RewriteRule ^wp-cron.php - [L]
  RewriteRule ^wp-mail.php - [L]
  # == WP Comments form
  RewriteRule ^wp-comments-post.php - [L]

  # (...) <-- I need to know which other files need to be allowed


  # BLOCK ALL OTHER SCRIPTS
  RewriteCond %{REQUEST_FILENAME} -f
  RewriteRule \\.(php.?|pl|cgi)$ - [F,L]
</IfModule>

3 个回复
最合适的回答,由SO网友:Rarst 整理而成

由于WP管理体系结构的原因,要可靠地编译和维护该列表将非常不方便。

我最有根据的猜测是,这些文件中的许多(但可能不是全部,也不仅仅是全部)都需要管理员引导(wp-admin/admin.php) 发挥作用。

我快速搜索了相应的指令,结果如下:

C:\\server\\www\\dev\\wordpress\\src>ack --files-with-matches --literal "require_once( dirname( __FILE__ ) . \'/admin.php\' );"
wp-admin/about.php
wp-admin/admin-header.php
wp-admin/comment.php
wp-admin/credits.php
wp-admin/customize.php
wp-admin/edit-comments.php
wp-admin/edit-tags.php
wp-admin/edit.php
wp-admin/export.php
wp-admin/freedoms.php
wp-admin/import.php
wp-admin/index.php
wp-admin/link-add.php
wp-admin/link-manager.php
wp-admin/link.php
wp-admin/media-new.php
wp-admin/media-upload.php
wp-admin/media.php
wp-admin/ms-admin.php
wp-admin/ms-delete-site.php
wp-admin/ms-edit.php
wp-admin/ms-options.php
wp-admin/ms-sites.php
wp-admin/ms-themes.php
wp-admin/ms-upgrade-network.php
wp-admin/ms-users.php
wp-admin/my-sites.php
wp-admin/nav-menus.php
wp-admin/network/about.php
wp-admin/network/credits.php
wp-admin/network/edit.php
wp-admin/network/freedoms.php
wp-admin/network/index.php
wp-admin/network/plugin-editor.php
wp-admin/network/plugin-install.php
wp-admin/network/plugins.php
wp-admin/network/profile.php
wp-admin/network/settings.php
wp-admin/network/setup.php
wp-admin/network/site-info.php
wp-admin/network/site-new.php
wp-admin/network/site-settings.php
wp-admin/network/site-themes.php
wp-admin/network/site-users.php
wp-admin/network/sites.php
wp-admin/network/theme-editor.php
wp-admin/network/theme-install.php
wp-admin/network/themes.php
wp-admin/network/update-core.php
wp-admin/network/update.php
wp-admin/network/upgrade.php
wp-admin/network/user-edit.php
wp-admin/network/user-new.php
wp-admin/network/users.php
wp-admin/network.php
wp-admin/options-discussion.php
wp-admin/options-general.php
wp-admin/options-media.php
wp-admin/options-permalink.php
wp-admin/options-reading.php
wp-admin/options-writing.php
wp-admin/options.php
wp-admin/plugin-editor.php
wp-admin/plugin-install.php
wp-admin/plugins.php
wp-admin/post-new.php
wp-admin/post.php
wp-admin/press-this.php
wp-admin/revision.php
wp-admin/term.php
wp-admin/theme-editor.php
wp-admin/theme-install.php
wp-admin/themes.php
wp-admin/tools.php
wp-admin/update-core.php
wp-admin/update.php
wp-admin/upload.php
wp-admin/user/about.php
wp-admin/user/credits.php
wp-admin/user/freedoms.php
wp-admin/user/index.php
wp-admin/user/profile.php
wp-admin/user/user-edit.php
wp-admin/user-edit.php
wp-admin/user-new.php
wp-admin/users.php
wp-admin/widgets.php

SO网友:Vinod Dalvi

WordPress文件/文件夹权限应如下所示。

目录:755

文件:644

以下情况除外:

/wp含量/774

/wp内容/主题/=755或775(设置为允许编辑)

/wp-content/plugins/=755一些插件会抱怨,但如果他们需要写访问权限,他们会让你知道。

/wp content/uploads/=775检查以递归方式仅应用于目录。此文件夹中的文件将具有不同的权限,具体取决于它们是什么。

Never use 777

以下页面提供的信息将对您有所帮助。

http://codex.wordpress.org/Changing_File_Permissionshttp://codex.wordpress.org/Hardening_WordPresshttps://stackoverflow.com/a/18352747/1287548http://www.smashingmagazine.com/2014/05/08/proper-wordpress-filesystem-permissions-ownerships/

允许/不允许使用执行文件。htaccess请参阅以下线程和页面中提供的答案。

https://stackoverflow.com/a/8415600/1287548https://stackoverflow.com/a/11950077/1287548http://www.wpbeginner.com/wp-tutorials/how-to-disable-php-execution-in-certain-wordpress-directories/http://perishablepress.com/stupid-htaccess-tricks/

SO网友:Vinnie James

我使用此bash命令快速轻松地重置WordPress文件权限,只需导航到您的根WP文件夹并同时运行:

目录

find . -type d -exec chmod 755 {} \\;

文件

find . -type f -exec chmod 644 {} \\;

结束

相关推荐

Modify the .htaccess file

我有一个非常简单的问题:我想修改。htaccess文件。看来我不是唯一一个人,我已经看到了其他问题,并在google上搜索了这个问题。没有任何帮助。某些内容不断覆盖该文件,有时会导致它在整个站点上抛出http 500。我已经知道或尝试的:我应该将自定义htaccess规则放在Wordpress块之外(标记为# BEGIN/END wordpress)</缓存插件还有另一个块。我的自定义规则也在这个区块之外</清空缓存或同时启用/禁用缓存不会触发问题</起初,我把我的自定义规则放在其他规则