为什么下面的代码段不起作用?
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^custom$ index.php?pagename=mypage [NC,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
当我导航到mydomain.com/custom
它时,它会给出一个 404 页面。如果我直接在我的 wordpress 中编写它,如下所示,它可以工作,但为什么它不能在 .htaccess 中工作?
add_action( 'init', 'add_alexes_rules' );
function add_alexes_rules() {
add_rewrite_rule('^custom$', 'index.php?pagename=mypage', 'top');
flush_rewrite_rules();
}