Wordpress上的文件安全性


File Security on Wordpress

是否有一些代码可以阻止直接访问我的主题文件。我对如何做有一个模糊的想法。

if(! defined('ABSPATH')){exit}; /*This is the best way right?*/

除此之外,我还需要采取其他代码预防措施来最大限度地提高安全性吗?

我认为这就足够了,但如果你想要更多的安全性,那么你应该让一些htaccess发挥作用,例如:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(www'.)?yourwebsite'.com/ [NC]
RewriteCond %{REQUEST_URI} !hotlink'.(gif|png|jpg|doc|xls|pdf|html|htm|xlsx|docx|mp4|mov) [NC]
RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]
RewriteRule .*'.(gif|png|jpg|doc|xls|pdf|html|htm|xlsx|docx|mp4|mov)$ http://yourwebsite.com/ [NC]