我在WordPress中使用functions.php创建了一些自定义菜单,我希望使用htaccess将这些URL重定向到友好的东西。例如,我在菜单中看到的其中一个自定义菜单如下:http://www.website.com/wp-admin/admin.php?page=for_buyers
如何重新编写它更像是这样:
http://www.website.com/wp-admin/for-buyers/
此外,我的自定义子菜单如下所示:
http://www.website.com/wp-admin/admin.php?page=marketing_materials
我希望它更像是这样:
http://www.website.com/wp-admin/for-buyers/marketing-materials/
答案 0 :(得分:1)
这还没有经过测试,最好是修改vhosts,但你可以使用perdir .htaccess:
在/.htaccess中,我们可以添加:RewriteCond ${REQUEST_FILENAME} !-d
RewriteCond ${REQUEST_FILENAME} !-f
RewriteRule ^wp-admin/for-buyers/$ /wp-admin/admin.php?page=for_buyers [L]
RewriteCond ${REQUEST_FILENAME} !-d
RewriteCond ${REQUEST_FILENAME} !-f
RewriteRule ^wp-admin/for-buyers/marketing-materials/$ /wp-admin/admin.php?page=marketing_materials [L]
此规则集执行此操作:
或者在/wp-admin/.htaccess中:
RewriteCond ${REQUEST_FILENAME} !-d
RewriteCond ${REQUEST_FILENAME} !-f
RewriteRule ^for-buyers/$ /wp-admin/admin.php?page=for_buyers [L]
RewriteCond ${REQUEST_FILENAME} !-d
RewriteCond ${REQUEST_FILENAME} !-f
RewriteRule ^for-buyers/marketing-materials/$ /wp-admin/admin.php?page=marketing_materials [L]