Wordpress .htaccess重写规则不工作

Wordpress .htaccess重写规则不工作,wordpress,.htaccess,url-rewriting,wp-rewrite,Wordpress,.htaccess,Url Rewriting,Wp Rewrite,为什么下面的代码块不工作 # 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

为什么下面的代码块不工作

# 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

重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-f
重写cond%{REQUEST_FILENAME}-d
重写规则/index.php[L]

可能
模块标题
模块不可用included@Deadooshka我删除了mod_头,它没有影响。如果您直接请求
/index.php?pagename=mypage
,它是否“起作用”?@user82217如果我将其写入浏览器,它就起作用。WP使用php服务器变量通过index.php处理请求,所以规则必须改变这个变量。问题是为什么他们的.htaccess代码不起作用。即使您提供了工作代码,如果您描述了为什么您的代码更好/问题是什么,这将是一个更好的答案。
add_action( 'init', 'add_alexes_rules' );
function add_alexes_rules() {
    add_rewrite_rule('^custom$', 'index.php?pagename=mypage', 'top');
    flush_rewrite_rules();
}
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>