1 如何隱藏WordPress代碼內(nèi)的版本號(hào)提示?
默認(rèn)情況下,當(dāng)你使用WordPress構(gòu)建網(wǎng)站時(shí),WordPress會(huì)在你的網(wǎng)站上留下版本號(hào)標(biāo)記。
由于某些特殊原因,如果你使用舊版本的軟件,暴露WordPress版本號(hào)可能會(huì)成為你網(wǎng)站的安全漏洞。
現(xiàn)在我們將告訴你如何隱藏WordPress版本號(hào)。
這是WordPress自動(dòng)生成的代碼,用于向外界宣布你使用的WordPress版本。
打開你的WordPress網(wǎng)站,右鍵單擊空白區(qū)域并選擇查看源代碼,通常你會(huì)發(fā)現(xiàn)這樣一行代碼:
<meta name="generator" content="WordPress 5.8.1" />
因此,在這種情況下,你應(yīng)該隱藏網(wǎng)站使用的WordPress版本號(hào)。
在你的WordPress網(wǎng)站中,有四個(gè)地方很容易公開WordPress的版本號(hào):
假設(shè)你的網(wǎng)站總是使用最新版本的WordPress,你基本上不必?fù)?dān)心由于泄露版本號(hào)而引起的安全問題。
在網(wǎng)絡(luò)上隱藏WordPress版本號(hào)有很多技巧,還有最完面、最簡(jiǎn)潔的代碼。
在模板的functions.php文件中,添加以下移除WordPress版本號(hào)的代碼:
/* 在 js 文件和 css 文件中隱藏 WordPress 版本號(hào) * @return {string} $src * @filter script_loader_src * @filter style_loader_src */ function cwl_remove_wp_version_strings( $src ) { global $wp_version; parse_str(parse_url($src, PHP_URL_QUERY), $query); if ( !empty($query['ver']) && $query['ver'] === $wp_version ) { $src = remove_query_arg('ver', $src); } return $src; } add_filter( 'script_loader_src', 'cwl_remove_wp_version_strings' ); add_filter( 'style_loader_src', 'cwl_remove_wp_version_strings' ); /* 在 generator meta 標(biāo)簽中隱藏 WordPress版本號(hào) */ function cwl_remove_version() { return ''; } add_filter('the_generator', 'cwl_remove_version');
mv readme.html readme.bak.html
當(dāng)然,上述做法隱藏了WordPress的版本號(hào),并不能完全有效解決網(wǎng)站中存在的安全漏洞。
建議使用Wordfence Security安全插件掃描網(wǎng)站惡意代碼。
希望我們網(wǎng)站( https://www.wordpressx.com/ ) 分享的《如何移除WordPress版本號(hào)?隱藏WordPress代碼內(nèi)版本號(hào)》,對(duì)您有幫助。