根据上的示例Adding your own .htaccess contents via WordPress 可以扩展。通过主题/插件访问htaccess文件。例如:
<?php
function my_htaccess_contents( $rules )
{
$my_content = <<<EOD
\\n # BEGIN My Added Content
# Protect wpconfig.php
<Files wp-config.php>
Order Allow,Deny
Deny from all
</Files>
# END My Added Content\\n
EOD;
return $my_content . $rules;
}
add_filter(\'mod_rewrite_rules\', \'my_htaccess_contents\');
将导致以下情况。htaccess文件:
# BEGIN My Added Content
# Protect wpconfig.php
<Files wp-config.php>
Order Allow,Deny
Deny from all
</Files>
# END My Added Content
RewriteEngine On
RewriteBase /
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
但不幸的是,它不适用于多站点。
有什么建议如何处理这个问题吗?