1
为什么以下代码段不起作用?.htaccess重写代码不工作
# 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();
}
也许'mod_headers'模块不包括 – Deadooshka
@Deadooshka我mod_headers中删除,并没有影响。 – HOY
如果您直接请求'/index.php?pagename=mypage',是否“有效”? – MrWhite