使用.htaccess的Wordpress自定义永久链接

8 php wordpress .htaccess

目前,我/post/%post_id%通过管理员中的永久链接设置为帖子添加了自定义结构.

因为我需要重写类别,标签和作者页面的永久链接,如下所示:

分类

目前/post/category/category_name来/category_name

标签

目前/post/tag/tag_name来tag/tag_name

作者

目前/post/author/author_username来/author/author_username

我试图在.htaccess中创建自定义的RewriteRule,它根本不起作用:

RewriteRule ^/([^/]*)$ ./post/category/$1 [L]
RewriteRule ^/tag/([^/]*)$ ./post/tag/$1 [L]
RewriteRule ^/author/([^/]*)$ ./post/auhtor/$1 [L]
Run Code Online (Sandbox Code Playgroud)

任何有关.htaccess规则编码以实现此类永久链接的帮助都非常受欢迎.

Nic*_*nia 1

我没有使用 WordPress 进行测试,而是使用http://htaccess.mwl.be/进行测试

你非常接近:

RewriteRule ^([^/]+)$ /post/category/$1 [L]
RewriteRule ^tag/([^/]+)$ /post/tag/$1 [L]
RewriteRule ^author/([^/]+)$ /post/author/$1 [L]
Run Code Online (Sandbox Code Playgroud)